On Aug 14, 2009, at 2:48 PM, Eli Friedman wrote:
On Fri, Aug 14, 2009 at 1:49 PM, Ted Kremenek<[email protected]>
wrote:
@@ -431,17 +438,18 @@
return;
}
- if (!isFunctionOrMethod(d)) {
+ if (!isFunction(d)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< Attr.getName() << 0 /*function*/;
return;
}
- if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
- if (!FD->getResultType()->isPointerType()) {
- S.Diag(Attr.getLoc(),
diag::warn_attribute_malloc_pointer_only);
- return;
- }
+ const FunctionDecl *FD = cast<FunctionDecl>(d);
+ QualType RetTy = FD->getResultType();
+
+ if (!(RetTy->isAnyPointerType() || RetTy->isBlockPointerType())) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);
+ return;
}
I believe we went through this before... isFunction doesn't guarantee
that d is a FunctionDecl.
In the previous discussion, the code involved 'isFunctionOrMethod',
which would return true for an ObjCMethodDecl. I just added
'isFunction'. When I read the previous objections to
cast<FunctionDecl>, I thought it was mainly because the Decl could be
an ObjCMethodDecl, but as you pointed out in your other email they are
certainly other cases._______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits