diff options
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 9 | ||||
-rw-r--r-- | clang/test/SemaTemplate/explicit-instantiation.cpp | 16 | ||||
-rw-r--r-- | clang/test/SemaTemplate/function-template-specialization-noreturn.cpp | 12 |
3 files changed, 31 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index c7608516036..67c36a5fb5e 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/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 diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp index 71121ad2b37..040a932e972 100644 --- a/clang/test/SemaTemplate/explicit-instantiation.cpp +++ b/clang/test/SemaTemplate/explicit-instantiation.cpp @@ -164,3 +164,19 @@ template void Foo(float a); // expected-error@+1 0-1 {{exception specification in explicit instantiation does not match instantiated one}} template void Foo(double a) noexcept; #endif + +#if __cplusplus >= 201103L +namespace PR21942 { +template <int> +struct A { + virtual void foo() final; +}; + +template <> +void A<0>::foo() {} // expected-note{{overridden virtual function is here}} + +struct B : A<0> { + virtual void foo() override; // expected-error{{declaration of 'foo' overrides a 'final' function}} +}; +} +#endif diff --git a/clang/test/SemaTemplate/function-template-specialization-noreturn.cpp b/clang/test/SemaTemplate/function-template-specialization-noreturn.cpp index 3e1f61855a5..672da272547 100644 --- a/clang/test/SemaTemplate/function-template-specialization-noreturn.cpp +++ b/clang/test/SemaTemplate/function-template-specialization-noreturn.cpp @@ -6,3 +6,15 @@ template <int N> void __attribute__((noreturn)) f3() { __builtin_unreachable(); } template <> void f3<1>() { } // expected-warning {{function declared 'noreturn' should not return}} + +#if __cplusplus >= 201103L +namespace PR21942 { +template <int> +struct A { + void foo[[noreturn]](); +}; + +template <> +void A<0>::foo() {} // expected-warning{{function declared 'noreturn' should not return}} +} +#endif |