summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-18 02:01:17 +0000
committerChris Lattner <sabre@nondot.org>2008-12-18 02:01:17 +0000
commit27e5beff70af8d3f945e53532ee73211d5d89047 (patch)
tree307532cb63fddb3752c18c3e60afa0e94d3c8ffa /clang/lib/Sema/SemaStmt.cpp
parent83682a9441b962e70e2dbffb72dfa6e968e5ac63 (diff)
downloadbcm5719-llvm-27e5beff70af8d3f945e53532ee73211d5d89047.tar.gz
bcm5719-llvm-27e5beff70af8d3f945e53532ee73211d5d89047.zip
Merge function-return.c into function.c
Fix PR2790 by making a warning an EXTWARN instead of EXTENSION. Add a new EXTENSION warning for "return (some void expression);" llvm-svn: 61187
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 21f897f639b..0604470c1dc 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -759,13 +759,14 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
if (FnRetType->isVoidType()) {
if (RetValExp) {// C99 6.8.6.4p1 (ext_ since GCC warns)
- if (FunctionDecl *FD = getCurFunctionDecl())
- Diag(ReturnLoc, diag::ext_return_has_expr)
- << FD->getIdentifier() << 0/*function*/<< RetValExp->getSourceRange();
- else
- Diag(ReturnLoc, diag::ext_return_has_expr)
- << getCurMethodDecl()->getDeclName() << 1 /*method*/
- << RetValExp->getSourceRange();
+ 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 new ReturnStmt(ReturnLoc, RetValExp);
}
OpenPOWER on IntegriCloud