<div dir="ltr"><div>Don't drop attributes when checking explicit specializations.</div><div><br></div><div>Consider a template class with attributes on a method, and an explicit</div><div>specialization of that method:</div><div><br></div><div>    template <int></div><div>    struct A {</div><div>      void foo() final;</div><div>    };</div><div><br></div><div>    template <></div><div>    void A<0>::foo() {}</div><div><br></div><div>In this example, the attribute is `final`, but it might also be an</div><div>__attribute__((visibility("foo"))), noreturn, inline, etc. clang's current</div><div>behavior is to strip all attributes, which for some attributes is wrong</div><div>(the snippet above allows a subclass of A<0> to override the final method, for</div><div>example) and for others disagrees with gcc (__attribute__((visibility()))).</div><div><br></div><div>So stop dropping attributes. r95845 added this code without a test case, and</div><div>r176728 added the code for dropping attributes on parameters (with tests, but</div><div>they still pass).</div><div><br></div><div>As an additional wrinkle, do drop dllimport and dllexport, since that's how these two</div><div>attributes work. (This is covered by existing tests.)</div><div><br></div><div>Fixes PR21942.</div><div><br></div><div>The approach is by Richard Smith, initial analysis and typing was done by me.</div><div><br></div><div>Nico</div><div><br></div></div>