PR15633: Note that we are EnteringContext when parsing the nested name

specifier for an enumeration. Also fix a crash-on-invalid if a non-dependent
name specifier is used to declare an enum template.

llvm-svn: 178502
This commit is contained in:
Richard Smith 2013-04-01 21:43:41 +00:00
parent d2c0abad2b
commit 1d4b2e16a2
5 changed files with 21 additions and 2 deletions

View File

@ -77,6 +77,7 @@ def note_decl_hiding_tag_type : Note<
"%1 %0 is hidden by a non-type declaration of %0 here">; "%1 %0 is hidden by a non-type declaration of %0 here">;
def err_attribute_not_type_attr : Error< def err_attribute_not_type_attr : Error<
"%0 attribute cannot be applied to types">; "%0 attribute cannot be applied to types">;
def err_enum_template : Error<"enumeration cannot be a template">;
// Sema && Lex // Sema && Lex
def ext_c99_longlong : Extension< def ext_c99_longlong : Extension<

View File

@ -556,7 +556,6 @@ def err_explicit_instantiation_with_definition : Error<
"explicit template instantiation cannot have a definition; if this " "explicit template instantiation cannot have a definition; if this "
"definition is meant to be an explicit specialization, add '<>' after the " "definition is meant to be an explicit specialization, add '<>' after the "
"'template' keyword">; "'template' keyword">;
def err_enum_template : Error<"enumeration cannot be a template">;
def err_explicit_instantiation_enum : Error< def err_explicit_instantiation_enum : Error<
"enumerations cannot be explicitly instantiated">; "enumerations cannot be explicitly instantiated">;
def err_expected_template_parameter : Error<"expected template parameter">; def err_expected_template_parameter : Error<"expected template parameter">;

View File

@ -3262,7 +3262,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
ColonProtectionRAIIObject X(*this, AllowFixedUnderlyingType); ColonProtectionRAIIObject X(*this, AllowFixedUnderlyingType);
if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
/*EnteringContext=*/false)) /*EnteringContext=*/true))
return; return;
if (SS.isSet() && Tok.isNot(tok::identifier)) { if (SS.isSet() && Tok.isNot(tok::identifier)) {

View File

@ -9387,6 +9387,11 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
TUK == TUK_Friend, TUK == TUK_Friend,
isExplicitSpecialization, isExplicitSpecialization,
Invalid)) { Invalid)) {
if (Kind == TTK_Enum) {
Diag(KWLoc, diag::err_enum_template);
return 0;
}
if (TemplateParams->size() > 0) { if (TemplateParams->size() > 0) {
// This is a declaration or definition of a class template (which may // This is a declaration or definition of a class template (which may
// be a member of another template). // be a member of another template).

View File

@ -252,3 +252,17 @@ namespace pr13128 {
enum class E { C }; enum class E { C };
}; };
} }
namespace PR15633 {
template<typename T> struct A {
struct B {
enum class E : T;
enum class E2 : T;
};
};
template<typename T> enum class A<T>::B::E { e };
template class A<int>;
struct B { enum class E; };
template<typename T> enum class B::E { e }; // expected-error {{enumeration cannot be a template}}
}