diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-03 17:48:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-03 17:48:54 +0000 |
commit | 8fc6d236b8d05bad4b41a9be689b26d931adedd5 (patch) | |
tree | f402573b575da8b65d82b43997e4939726fa3c2d /lib/Parse/ParseDecl.cpp | |
parent | 32897fd3bd84e96d4bfa28aca0c7a907776fb855 (diff) |
It's okay to reference an enum in a template definition, even though
it's ill-formed to form an enum template. Fixes <rdar://problem/7933063>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 6669d40cca..91050e0a4c 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1900,15 +1900,6 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, return; } - // enums cannot be templates. - if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) { - Diag(Tok, diag::err_enum_template); - - // Skip the rest of this declarator, up until the comma or semicolon. - SkipUntil(tok::comma, true); - return; - } - // If an identifier is present, consume and remember it. IdentifierInfo *Name = 0; SourceLocation NameLoc; @@ -1932,6 +1923,18 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, TUK = Action::TUK_Declaration; else TUK = Action::TUK_Reference; + + // enums cannot be templates, although they can be referenced from a + // template. + if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate && + TUK != Action::TUK_Reference) { + Diag(Tok, diag::err_enum_template); + + // Skip the rest of this declarator, up until the comma or semicolon. + SkipUntil(tok::comma, true); + return; + } + bool Owned = false; bool IsDependent = false; SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc; |