diff options
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 0092d5dab1..f2e840494f 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5691,6 +5691,14 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, ProcessDeclAttributes(S, NewFD, D, /*NonInheritable=*/false, /*Inheritable=*/true); + QualType RetType = NewFD->getResultType(); + const CXXRecordDecl *Ret = RetType->isRecordType() ? + RetType->getAsCXXRecordDecl() : RetType->getPointeeCXXRecordDecl(); + if (!NewFD->isInvalidDecl() && !NewFD->hasAttr<WarnUnusedResultAttr>() && + Ret && Ret->hasAttr<WarnUnusedResultAttr>()) { + NewFD->addAttr(new (Context) WarnUnusedResultAttr(SourceRange(), Context)); + } + if (!getLangOpts().CPlusPlus) { // Perform semantic checking on the function declaration. bool isExplicitSpecialization=false; |