forked from OSchip/llvm-project
Diagnose explicit instantiations and specializations that occur in class scope
llvm-svn: 83473
This commit is contained in:
parent
ae01f78a31
commit
40fb74484e
|
@ -927,6 +927,9 @@ def note_specialized_entity : Note<
|
|||
def err_template_spec_decl_function_scope : Error<
|
||||
"explicit %select{<error>|<error>|specialization|instantiation|"
|
||||
"instantiation}0 of %1 in function scope">;
|
||||
def err_template_spec_decl_class_scope : Error<
|
||||
"explicit %select{<error>|<error>|specialization|instantiation|"
|
||||
"instantiation}0 of %1 in class scope">;
|
||||
def err_template_spec_decl_out_of_scope_global : Error<
|
||||
"%select{class template|class template partial|function template|member "
|
||||
"function|static data member|member class}0 specialization of %1 must "
|
||||
|
|
|
@ -2433,11 +2433,13 @@ static bool CheckTemplateSpecializationScope(Sema &S,
|
|||
<< TSK << Specialized;
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: For everything except class template partial specializations,
|
||||
// complain if the explicit specialization/instantiation occurs at class
|
||||
// scope.
|
||||
|
||||
if (S.CurContext->isRecord() && !IsPartialSpecialization) {
|
||||
S.Diag(Loc, diag::err_template_spec_decl_class_scope)
|
||||
<< TSK << Specialized;
|
||||
return true;
|
||||
}
|
||||
|
||||
// C++ [temp.class.spec]p6:
|
||||
// A class template partial specialization may be declared or redeclared
|
||||
// in any namespace scope in which its definition may be defined (14.5.1
|
||||
|
|
|
@ -38,6 +38,12 @@ namespace N1 {
|
|||
|
||||
template<> void N0::f0(double) { } // expected-error{{originally be declared}}
|
||||
|
||||
struct X1 {
|
||||
template<typename T> void f(T);
|
||||
|
||||
template<> void f(int); // expected-error{{in class scope}}
|
||||
};
|
||||
|
||||
// -- class template
|
||||
namespace N0 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue