diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 15 | ||||
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 4 |
2 files changed, 4 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ce183d0adf4..1bad38f53b8 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7489,23 +7489,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Handle attributes. ProcessDeclAttributes(S, NewFD, D); - QualType RetType = NewFD->getReturnType(); - const CXXRecordDecl *Ret = RetType->isRecordType() ? - RetType->getAsCXXRecordDecl() : RetType->getPointeeCXXRecordDecl(); - if (!NewFD->isInvalidDecl() && !NewFD->hasAttr<WarnUnusedResultAttr>() && - Ret && Ret->hasAttr<WarnUnusedResultAttr>()) { - const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD); - // Attach WarnUnusedResult to functions returning types with that attribute. - // Don't apply the attribute to that type's own non-static member functions - // (to avoid warning on things like assignment operators) - if (!MD || MD->getParent() != Ret) - NewFD->addAttr(WarnUnusedResultAttr::CreateImplicit(Context)); - } - if (getLangOpts().OpenCL) { // OpenCL v1.1 s6.5: Using an address space qualifier in a function return // type declaration will generate a compilation error. - unsigned AddressSpace = RetType.getAddressSpace(); + unsigned AddressSpace = NewFD->getReturnType().getAddressSpace(); if (AddressSpace == LangAS::opencl_local || AddressSpace == LangAS::opencl_global || AddressSpace == LangAS::opencl_constant) { diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 5774f53c060..8b174f8d922 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -239,7 +239,9 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { // is written in a macro body, only warn if it has the warn_unused_result // attribute. if (const Decl *FD = CE->getCalleeDecl()) { - if (FD->hasAttr<WarnUnusedResultAttr>()) { + const FunctionDecl *Func = dyn_cast<FunctionDecl>(FD); + if (Func ? Func->hasUnusedResultAttr() + : FD->hasAttr<WarnUnusedResultAttr>()) { Diag(Loc, diag::warn_unused_result) << R1 << R2; return; } |