[cfe-commits] r61188 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/SemaCXX/statements.cpp
Chris Lattner
sabre at nondot.org
Wed Dec 17 18:03:49 PST 2008
Author: lattner
Date: Wed Dec 17 20:03:48 2008
New Revision: 61188
URL: http://llvm.org/viewvc/llvm-project?rev=61188&view=rev
Log:
This is valid in C++.
void foo() { return foo(); }
Added:
cfe/trunk/test/SemaCXX/statements.cpp
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=61188&r1=61187&r2=61188&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Dec 17 20:03:48 2008
@@ -762,11 +762,15 @@
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);
}
Added: cfe/trunk/test/SemaCXX/statements.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/statements.cpp?rev=61188&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/statements.cpp (added)
+++ cfe/trunk/test/SemaCXX/statements.cpp Wed Dec 17 20:03:48 2008
@@ -0,0 +1,5 @@
+// RUN: clang %s -fsyntax-only -pedantic
+
+void foo() {
+ return foo();
+}
More information about the cfe-commits
mailing list