[patch] Don't drop attributes when checking explicit specializations.
Nico Weber
thakis at chromium.org
Wed Dec 17 18:58:45 PST 2014
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/20141217/75086a8c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-explattr.patch
Type: application/octet-stream
Size: 2275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141217/75086a8c/attachment.obj>
More information about the cfe-commits
mailing list