<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Dec 18, 2014, at 6:18 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 17, 2014 at 6:58 PM, Nico Weber <span dir="ltr" class=""><<a href="mailto:thakis@chromium.org" target="_blank" class="">thakis@chromium.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">Don't drop attributes when checking explicit specializations.</div><div class=""><br class=""></div><div class="">Consider a template class with attributes on a method, and an explicit</div><div class="">specialization of that method:</div><div class=""><br class=""></div><div class=""> template <int></div><div class=""> struct A {</div><div class=""> void foo() final;</div><div class=""> };</div><div class=""><br class=""></div><div class=""> template <></div><div class=""> void A<0>::foo() {}</div><div class=""><br class=""></div><div class="">In this example, the attribute is `final`, but it might also be an</div><div class="">__attribute__((visibility("foo"))), noreturn, inline, etc. clang's current</div><div class="">behavior is to strip all attributes, which for some attributes is wrong</div><div class="">(the snippet above allows a subclass of A<0> to override the final method, for</div><div class="">example) and for others disagrees with gcc (__attribute__((visibility()))).</div><div class=""><br class=""></div><div class="">So stop dropping attributes. r95845 added this code without a test case, and</div><div class="">r176728 added the code for dropping attributes on parameters (with tests, but</div><div class="">they still pass).</div><div class=""><br class=""></div><div class="">As an additional wrinkle, do drop dllimport and dllexport, since that's how these two</div><div class="">attributes work. (This is covered by existing tests.)</div><div class=""><br class=""></div><div class="">Fixes PR21942.</div><div class=""><br class=""></div><div class="">The approach is by Richard Smith, initial analysis and typing was done by me.</div></div></blockquote><div class=""><br class=""></div><div class="">Naturally, this makes sense to me =) It also matches GCC and EDG on all attributes I tested.</div><div class=""><br class=""></div><div class="">John, do you remember why you added this code (a long long time ago)?</div></div></div></div>
</div></blockquote></div><br class=""><div class="">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.</div><div class=""><br class=""></div><div class="">We definitely shouldn’t be dropping *all* attributes, though.</div><div class=""><br class=""></div><div class="">John.</div></body></html>