diff options
author | Chris Lattner <sabre@nondot.org> | 2008-12-18 02:03:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-12-18 02:03:48 +0000 |
commit | e878eb035b343d7d819c092102364ec9849716ae (patch) | |
tree | 738b6a772437a252464b651f12db632520208a3d /lib/Sema/SemaStmt.cpp | |
parent | 65ce04bef06696379682410f399f37b43996d824 (diff) |
This is valid in C++.
void foo() { return foo(); }
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61188 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 0604470c1d..97cad60a19 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -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); } |