[cfe-dev] merging attributes

Eric Niebler eric at boostpro.com
Fri Dec 10 08:11:53 PST 2010


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.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com



More information about the cfe-dev mailing list