This is valid in C++.

void foo() { return foo(); }

llvm-svn: 61188
This commit is contained in:
Chris Lattner 2008-12-18 02:03:48 +00:00
parent 27e5beff70
commit 0cb00d66ea
2 changed files with 13 additions and 4 deletions

View File

@ -762,11 +762,15 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
unsigned D = diag::ext_return_has_expr;
if (RetValExp->getType()->isVoidType())
D = diag::ext_return_has_void_expr;
NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
Diag(ReturnLoc, D)
<< CurDecl->getDeclName() << isa<ObjCMethodDecl>(CurDecl)
<< RetValExp->getSourceRange();
// return (some void expression); is legal in C++.
if (D != diag::ext_return_has_void_expr ||
!getLangOptions().CPlusPlus) {
NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
Diag(ReturnLoc, D)
<< CurDecl->getDeclName() << isa<ObjCMethodDecl>(CurDecl)
<< RetValExp->getSourceRange();
}
}
return new ReturnStmt(ReturnLoc, RetValExp);
}

View File

@ -0,0 +1,5 @@
// RUN: clang %s -fsyntax-only -pedantic
void foo() {
return foo();
}