> On Dec 18, 2014, at 6:18 PM, Richard Smith <[email protected]> wrote:
> On Wed, Dec 17, 2014 at 6:58 PM, Nico Weber <[email protected] 
> <mailto:[email protected]>> wrote:
> Don't drop attributes when checking explicit specializations.
> 
> Consider a template class with attributes on a method, and an explicit
> specialization of that method:
> 
>     template <int>
>     struct A {
>       void foo() final;
>     };
> 
>     template <>
>     void A<0>::foo() {}
> 
> In this example, the attribute is `final`, but it might also be an
> __attribute__((visibility("foo"))), noreturn, inline, etc. clang's current
> behavior is to strip all attributes, which for some attributes is wrong
> (the snippet above allows a subclass of A<0> to override the final method, for
> example) and for others disagrees with gcc (__attribute__((visibility()))).
> 
> So stop dropping attributes. r95845 added this code without a test case, and
> r176728 added the code for dropping attributes on parameters (with tests, but
> they still pass).
> 
> As an additional wrinkle, do drop dllimport and dllexport, since that's how 
> these two
> attributes work. (This is covered by existing tests.)
> 
> Fixes PR21942.
> 
> The approach is by Richard Smith, initial analysis and typing was done by me.
> 
> Naturally, this makes sense to me =) It also matches GCC and EDG on all 
> attributes I tested.
> 
> John, do you remember why you added this code (a long long time ago)?

The behavior on attribute((visibility)) is intentional, I think.  At the very 
least, you have to allow for explicit specializations to override the 
visibility of the template, using a general most-specific-rule-wins logic.  
There may be other attributes like this.

We definitely shouldn’t be dropping *all* attributes, though.

John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to