[patch] Don't drop attributes when checking explicit specializations.

Jordan Rose jordan_rose at apple.com
Fri Dec 19 09:36:01 PST 2014


I looked back at my commit to see if I have any comments and now I can't remember why that needed to be there. The commit and the Radar are both about preserving attributes, not dropping them, so I'm not going to worry about this one.

Jordan


> On Dec 18, 2014, at 10:30 , Nico Weber <thakis at chromium.org> wrote:
> 
> (+Jordan as he wrote r176728)
> 
> On Wed, Dec 17, 2014 at 6:58 PM, Nico Weber <thakis at chromium.org <mailto:thakis at chromium.org>> 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.
> 
> Nico
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141219/c13f4843/attachment.html>


More information about the cfe-commits mailing list