diff options
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 84ee2073382..718db0437f4 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -47,7 +47,7 @@ static const FunctionType *getFunctionType(const Decl *d, // FIXME: We should provide an abstraction around a method or function // to provide the following bits of information. -/// isFunctionOrMethod - Return true if the given decl has function +/// isFunction - Return true if the given decl has function /// type (function or function-typed variable). static bool isFunction(const Decl *d) { return getFunctionType(d, false) != NULL; @@ -731,14 +731,13 @@ static void HandleWarnUnusedResult(Decl *D, const AttributeList &Attr, Sema &S) } // TODO: could also be applied to methods? - FunctionDecl *Fn = dyn_cast<FunctionDecl>(D); - if (!Fn) { + if (!isFunctionOrMethod(D)) { S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << Attr.getName() << 0 /*function*/; return; } - Fn->addAttr(::new (S.Context) WarnUnusedResultAttr()); + D->addAttr(::new (S.Context) WarnUnusedResultAttr()); } static void HandleWeakAttr(Decl *D, const AttributeList &Attr, Sema &S) { diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index c2a3a3a8ca6..6a68db75eae 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -96,7 +96,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { if (const CallExpr *CE = dyn_cast<CallExpr>(E)) { // If the callee has attribute pure, const, or warn_unused_result, warn with // a more specific message to make it clear what is happening. - if (const FunctionDecl *FD = CE->getDirectCallee()) { + if (const Decl *FD = CE->getCalleeDecl()) { if (FD->getAttr<WarnUnusedResultAttr>()) { Diag(Loc, diag::warn_unused_call) << R1 << R2 << "warn_unused_result"; return; |

