diff options
author | Kaelyn Uhrain <rikka@google.com> | 2012-11-13 21:23:31 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2012-11-13 21:23:31 +0000 |
commit | 97c81bfaf0b6c90576081c5af7ea22fab6f2b7f9 (patch) | |
tree | e2436064a2938d7eef35395fa7fe83e3b4f0a188 /lib/Sema/SemaDecl.cpp | |
parent | 2ccecfaa4852c134191d4075d94e09399ab46fea (diff) |
For classes that have the warn_unused_result attribute, don't apply the
attribute to the class' methods even when they return an instance of the
class (e.g. assignment operators).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f2e840494f..04f66e5882 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5696,7 +5696,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, RetType->getAsCXXRecordDecl() : RetType->getPointeeCXXRecordDecl(); if (!NewFD->isInvalidDecl() && !NewFD->hasAttr<WarnUnusedResultAttr>() && Ret && Ret->hasAttr<WarnUnusedResultAttr>()) { - NewFD->addAttr(new (Context) WarnUnusedResultAttr(SourceRange(), Context)); + const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD); + if (!(MD && MD->getCorrespondingMethodInClass(Ret, true))) { + NewFD->addAttr(new (Context) WarnUnusedResultAttr(SourceRange(), + Context)); + } } if (!getLangOpts().CPlusPlus) { |