[cfe-commits] r79041 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Ted Kremenek kremenek at apple.com
Fri Aug 14 15:25:53 PDT 2009

On Aug 14, 2009, at 3:20 PM, Eli Friedman wrote:

> On Fri, Aug 14, 2009 at 3:12 PM, Ted Kremenek<kremenek at apple.com>  
> wrote:
>> 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.
> I think it's better to be self-consistent here over being consistent
> with gcc, as long as we don't break compatibility.  Function
> attributes are confusing enough without making different attributes
> act differently.

Thanks for the feedback Eli.  In the case of function pointers, I'm  
not certain what value there is with attaching the 'malloc' attribute  
to variable declarations.  The proper way to handle function pointer  
seems (to me) to associate it with the type.  Since this is a GCC  
extension, I'd rather follow GCC's more limited functionality here  
than have a half-baked one for function pointers unless we want to  
really handle it properly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090814/5db4371c/attachment.html>

More information about the cfe-commits mailing list