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

Nico Weber thakis at chromium.org
Thu Dec 18 10:30:00 PST 2014


(+Jordan as he wrote r176728)

On Wed, Dec 17, 2014 at 6:58 PM, Nico Weber <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/20141218/7a4cb85c/attachment.html>


More information about the cfe-commits mailing list