[cfe-commits] r79041 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp
eli.friedman at gmail.com
Fri Aug 14 15:38:19 PDT 2009
On Fri, Aug 14, 2009 at 3:30 PM, Chris Lattner<clattner at apple.com> wrote:
> 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)();
>>> I implemented handling of this case, but I noticed that GCC actually
>>> 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.
> The problem is that this attribute is really a decl attribute, not a type
> attribute. If I have two functions with the same prototype (but one is
> attribute malloc) I should be able to assign them to the same function
> pointer, no? If we made it part of the type system, we'd have to consider
> the attribute for assignment compatibility etc.
How is malloc different from noreturn in this regard?
More information about the cfe-commits