summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-12-19 23:52:45 +0000
committerNico Weber <nicolasweber@gmx.de>2014-12-19 23:52:45 +0000
commit6426e17f2c3bc515da685e99baa337592f511cea (patch)
tree5725b23665296496a8fb04ec9d7a3aac4aa066cf /lib/Sema/SemaTemplate.cpp
parent59265c5c860e55bfe9a4ea1e9281266797845207 (diff)
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. 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. With this, clang also matches GCC and EDG on all attributes Richard tested. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r--lib/Sema/SemaTemplate.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index c760851603..67c36a5fb5 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -6434,14 +6434,11 @@ Decl *Sema::ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
/// \brief Strips various properties off an implicit instantiation
/// that has just been explicitly specialized.
static void StripImplicitInstantiation(NamedDecl *D) {
- D->dropAttrs();
+ D->dropAttr<DLLImportAttr>();
+ D->dropAttr<DLLExportAttr>();
- if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
FD->setInlineSpecified(false);
-
- for (auto I : FD->params())
- I->dropAttrs();
- }
}
/// \brief Compute the diagnostic location for an explicit instantiation