Index: lib/Sema/SemaTemplate.cpp =================================================================== --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -843,8 +843,7 @@ bool Invalid = false; // Check that we can declare a template here. - if (CheckTemplateDeclScope(S, TemplateParams)) - return true; + CheckTemplateDeclScope(S, TemplateParams); TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec); assert(Kind != TTK_Enum && "can't build template of enumerated type"); Index: test/SemaTemplate/class-template-decl.cpp =================================================================== --- test/SemaTemplate/class-template-decl.cpp +++ test/SemaTemplate/class-template-decl.cpp @@ -152,3 +152,10 @@ T &pT = T(); pT; } + +extern "C" { + namespace ns11416 { + template class Sphere_d; //expected-error{{templates must have C++ linkage}} + template bool equal_as_sets(const Sphere_d&, const Sphere_d&); //expected-error{{templates must have C++ linkage}} + } +}