diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-06-30 08:56:22 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-06-30 08:56:22 +0000 |
commit | ca0d0d4a0d6ecd256d4bf8c1a0dc183a83119833 (patch) | |
tree | a2e5b8b259d9a8f956becb3b925ad5b26110f2d1 /lib/Sema/SemaStmt.cpp | |
parent | 146060435c3efce95c95a092c7a1eb651cfb9ae0 (diff) |
Improve the wording of the warning when returning a value from
a constructor or destructor.
Patch by Hans Wennborg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 75124c1908..164c0ce038 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -1761,8 +1761,17 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { if (D != diag::ext_return_has_void_expr || !getLangOptions().CPlusPlus) { NamedDecl *CurDecl = getCurFunctionOrMethodDecl(); + + int FunctionKind = 0; + if (isa<ObjCMethodDecl>(CurDecl)) + FunctionKind = 1; + else if (isa<CXXConstructorDecl>(CurDecl)) + FunctionKind = 2; + else if (isa<CXXDestructorDecl>(CurDecl)) + FunctionKind = 3; + Diag(ReturnLoc, D) - << CurDecl->getDeclName() << isa<ObjCMethodDecl>(CurDecl) + << CurDecl->getDeclName() << FunctionKind << RetValExp->getSourceRange(); } } |