diff options
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 15 |
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); } |