[PATCH] MS ABI: Propagate class-level DLL attributes to class template specialization bases (PR11170)

Hans Wennborg hans at chromium.org
Tue Jun 24 10:00:56 PDT 2014

On Mon, Jun 23, 2014 at 5:28 PM, Hans Wennborg <hans at chromium.org> wrote:
> On Mon, Jun 23, 2014 at 5:13 PM, Reid Kleckner <rnk at google.com> wrote:
>> Does your code handle explicit template specializations with inconsistent DLL attributes?  I'm thinking of this test case:
>>   template <typename T> struct Foo { T get() { return {}; } };
>>   template <> struct __declspec(dllimport) Foo<int> { int get() { return 42; } };
>>   struct __declspec(dllexport) Bar : Foo<int> {
>>     int baz() { return Foo<int>::get(); }
>>   };
>>   Bar b;
>> MSVC appears to import Foo<int>::get(), but if I understand your code correctly, it will diagnose this.
> Interesting. I guess they don't try to propagate the attribute to
> explicit specializations, which makes sense. I'll see if I can make my
> patch not warn here, and check if this applies to partial
> specializations too.

I played with your example some more. It seems that if Foo<int> is
explicitly specialized or explicit instantiated with a dll attribute,
they don't change that. But if it's explicitly instantiated or
specialized without an attribute, they will propagate Bar's attribute
to it. I'll change my code to not warn in the former case.

More information about the cfe-commits mailing list