summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2009-12-20 23:11:08 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2009-12-20 23:11:08 +0000
commit518e37071916d433aea03a8bd33087fd68abd7e5 (patch)
tree93637d1fa20056dbf64bb6718878b5bd2b84ddb1 /clang/lib/Sema/SemaDeclAttr.cpp
parent1576850a7636fd7b4b77ea31762b58fb140ac969 (diff)
downloadbcm5719-llvm-518e37071916d433aea03a8bd33087fd68abd7e5.tar.gz
bcm5719-llvm-518e37071916d433aea03a8bd33087fd68abd7e5.zip
fix PR4010: add support for the warn_unused_result for function pointers
llvm-svn: 91803
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp7
1 files changed, 3 insertions, 4 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) {
OpenPOWER on IntegriCloud