From 0cb00d66eab14719baa8a45d078ec0044d2bd240 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 18 Dec 2008 02:03:48 +0000 Subject: This is valid in C++. void foo() { return foo(); } llvm-svn: 61188 --- clang/lib/Sema/SemaStmt.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'clang/lib/Sema/SemaStmt.cpp') 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(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(CurDecl) + << RetValExp->getSourceRange(); + } } return new ReturnStmt(ReturnLoc, RetValExp); } -- cgit v1.2.3