Template attributes lose their inherited flag on instantiations

Hi,

I noticed that when a template is instanciated and all attributes are pulled over (using sema::instantiateTemplateAttribute), inheritable attributes lose their inherited flag. Is this a bug/an oversight or intended behavior?

In my case the inherited status is used to distinguish between DLLImportAttr/DLLExportAttr applied directly to class members and inherited from the class. When those attributes are applied to a class template, and in turn applied to class members with the inherited flag set, this distinction is lost for the members of the template instantiation.

I changed the generated code to propagate the flag and it doesn't seem to break anything. So at least nothing tested seems to rely on that.

-Nico

Don't we apply dllexport only to variables and functions? How are you
applying it to classes?

Cheers,
Rafael

If it is applied to the class, then it automatically applies to all member functions and static fields. This is already implemented, by iterating over those members and giving them an inherited import/export attribute.
But as stated, this breaks for class templates. And the distinction is needed because specifying the attributes both on the class and a member is forbidden.

-Nico

If it is applied to the class, then it automatically applies to all member
functions and static fields. This is already implemented, by iterating over
those members and giving them an inherited import/export attribute.
But as stated, this breaks for class templates. And the distinction is
needed because specifying the attributes both on the class and a member is
forbidden.

Sorry, what is the syntax. I am trying

class __attribute__((dllexport)) foo {
};

and I get

warning: 'dllexport' attribute only applies to variables and functions

-Nico

Cheers,
Rafael

Ah, my bad. The syntax is indeed correct, but isn't actually implemented yet. I started off with an older patch, that's why I didn't remember writing it.

-Nico