diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 82ff7c0ca4f50774e0151d3a71f8a19c2064eed4..178a14e9ecc00dc85554910482cbbefcf6888b7b 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -2269,33 +2269,6 @@ bool Sema::InstantiateClassTemplateSpecialization( // Perform the actual instantiation on the canonical declaration. ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>( ClassTemplateSpec->getCanonicalDecl()); - - // Check whether we have already instantiated or specialized this class - // template specialization. - if (ClassTemplateSpec->getSpecializationKind() != TSK_Undeclared) { - if (ClassTemplateSpec->getSpecializationKind() == - TSK_ExplicitInstantiationDeclaration && - TSK == TSK_ExplicitInstantiationDefinition) { - // An explicit instantiation definition follows an explicit instantiation - // declaration (C++0x [temp.explicit]p10); go ahead and perform the - // explicit instantiation. - ClassTemplateSpec->setSpecializationKind(TSK); - - // If this is an explicit instantiation definition, mark the - // vtable as used. - if (TSK == TSK_ExplicitInstantiationDefinition && - !ClassTemplateSpec->isInvalidDecl()) - MarkVTableUsed(PointOfInstantiation, ClassTemplateSpec, true); - - return false; - } - - // We can only instantiate something that hasn't already been - // instantiated or specialized. Fail without any diagnostics: our - // caller will provide an error message. - return true; - } - if (ClassTemplateSpec->isInvalidDecl()) return true; diff --git a/test/SemaTemplate/instantiate-explicitly-after-fatal.cpp b/test/SemaTemplate/instantiate-explicitly-after-fatal.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9693d2fc6c059bad1219e6569aaf043007cbb42c --- /dev/null +++ b/test/SemaTemplate/instantiate-explicitly-after-fatal.cpp @@ -0,0 +1,9 @@ +// RUN: not %clang_cc1 -fsyntax-only -std=c++11 -ferror-limit 1 %s 2>&1 | FileCheck %s +unknown_type foo(unknown_type); +// CHECK: fatal error: too many errors emitted, stopping now + +template <typename> +class Bar {}; + +extern template class Bar<int>; +template class Bar<int>;