[cfe-dev] merging attributes

Douglas Gregor dgregor at apple.com
Fri Dec 10 08:55:52 PST 2010


On Dec 10, 2010, at 8:11 AM, Eric Niebler wrote:

> On 12/9/2010 2:07 PM, Eric Niebler wrote:
>> Simple Q: looks like attributes are automatically merged on functions
>> and variables, but not on records (struct/class/union). Any particular
>> reason? If I wanted to get an attribute from a struct forward
>> declaration onto the full declaration, where would that go?
> 
> I have a solution that works for me locally. In Sema::ActOnTag, right
> after this:
> 
>  if (Attr)
>    ProcessDeclAttributeList(S, New, Attr);
> 
> I have added this:
> 
>  // If the previous decl has attributes, apply them to the current
>  // declaration also.
>  if (PrevDecl)
>    MergeDeclAttributes(New, PrevDecl, Context);
> 
> This has the effect of getting attributes from struct forward
> declarations to their definitions. Holler if you think this is bogus.

This seems completely reasonable.

	- Doug



More information about the cfe-dev mailing list