Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp	(revision 224345)
+++ lib/Sema/SemaTemplate.cpp	(working copy)
@@ -6431,14 +6431,11 @@
 /// \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
Index: test/SemaTemplate/explicit-instantiation.cpp
===================================================================
--- test/SemaTemplate/explicit-instantiation.cpp	(revision 224345)
+++ test/SemaTemplate/explicit-instantiation.cpp	(working copy)
@@ -164,3 +164,19 @@
 // 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
Index: test/SemaTemplate/function-template-specialization-noreturn.cpp
===================================================================
--- test/SemaTemplate/function-template-specialization-noreturn.cpp	(revision 224345)
+++ test/SemaTemplate/function-template-specialization-noreturn.cpp	(working copy)
@@ -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
