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);"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61187 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 21f897f..0604470 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -759,13 +759,14 @@
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);
}