summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-18 02:03:48 +0000
committerChris Lattner <sabre@nondot.org>2008-12-18 02:03:48 +0000
commit0cb00d66eab14719baa8a45d078ec0044d2bd240 (patch)
tree54846c7e3dbf0eb6c25fbcb3654d1a9920fd59fb /clang/lib/Sema/SemaStmt.cpp
parent27e5beff70af8d3f945e53532ee73211d5d89047 (diff)
downloadbcm5719-llvm-0cb00d66eab14719baa8a45d078ec0044d2bd240.tar.gz
bcm5719-llvm-0cb00d66eab14719baa8a45d078ec0044d2bd240.zip
This is valid in C++.
void foo() { return foo(); } llvm-svn: 61188
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 0604470c1dc..97cad60a19f 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud