[cfe-commits] r79041 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Ted Kremenek
kremenek at apple.com
Fri Aug 14 15:12:31 PDT 2009
On Aug 14, 2009, at 2:51 PM, Eli Friedman wrote:
> On Fri, Aug 14, 2009 at 1:51 PM, Ted Kremenek<kremenek at apple.com>
> wrote:
>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Aug 14 15:51:58 2009
>> @@ -438,13 +438,14 @@
>> return;
>> }
>>
>> - if (!isFunction(d)) {
>> + const FunctionDecl *FD = dyn_cast<FunctionDecl>(d);
>> +
>> + if (!FD) {
>> S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
>> << Attr.getName() << 0 /*function*/;
>> return;
>> }
>
> Unless I'm mistaken, this breaks constructs like the following:
> __attribute((malloc)) void *(*f)();
>
> -Eli
I implemented handling of this case, but I noticed that GCC actually
rejects attribute 'malloc' being applied to function pointers
("warning: 'malloc' attribute ignored"). Should we do the same in
Clang? For function pointers, the malloc attribute really a property
of the pointer type, not the declaration, but apparently GCC doesn't
even reason about that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090814/8cc083bc/attachment.html>
More information about the cfe-commits
mailing list