summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-03 17:48:54 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-03 17:48:54 +0000
commitcbbf3e3b4af485a09042919dfa264b90ec6cd9cb (patch)
tree9d35a74c158079335a395d3109560a281083a358 /clang/lib/Parse/ParseDecl.cpp
parentd18dc2c87600db6173ee1d8ff69bea1ad13fd0e3 (diff)
downloadbcm5719-llvm-cbbf3e3b4af485a09042919dfa264b90ec6cd9cb.tar.gz
bcm5719-llvm-cbbf3e3b4af485a09042919dfa264b90ec6cd9cb.zip
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>. llvm-svn: 102926
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 6669d40cca0..91050e0a4cf 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud