This is valid in C++.
void foo() { return foo(); } llvm-svn: 61188
This commit is contained in:
parent
27e5beff70
commit
0cb00d66ea
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// RUN: clang %s -fsyntax-only -pedantic
|
||||
|
||||
void foo() {
|
||||
return foo();
|
||||
}
|
Loading…
Reference in New Issue