summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-06-23 22:30:04 +0000
committerJohn McCall <rjmccall@apple.com>2012-06-23 22:30:04 +0000
commitbeae29a5f4bf7558d4a59a0277c9c14f8f51760c (patch)
tree4e97927d854700ac869be3a15f3d0a5d5e1ba5d3
parent4b06b1a0ee5955ba7a50e89115de67bb28a1ffad (diff)
downloadbcm5719-llvm-beae29a5f4bf7558d4a59a0277c9c14f8f51760c.tar.gz
bcm5719-llvm-beae29a5f4bf7558d4a59a0277c9c14f8f51760c.zip
Recognize GNU attributes after 'enum class'. Fixes the libc++ build.
llvm-svn: 159089
-rw-r--r--clang/lib/Parse/ParseDecl.cpp9
-rw-r--r--clang/test/Parser/cxx0x-attributes.cpp5
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 8c24f9761f4..96c57581e85 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2976,15 +2976,22 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
SourceLocation ScopedEnumKWLoc;
bool IsScopedUsingClassTag = false;
+ // In C++11, recognize 'enum class' and 'enum struct'.
if (getLangOpts().CPlusPlus0x &&
(Tok.is(tok::kw_class) || Tok.is(tok::kw_struct))) {
Diag(Tok, diag::warn_cxx98_compat_scoped_enum);
IsScopedUsingClassTag = Tok.is(tok::kw_class);
ScopedEnumKWLoc = ConsumeToken();
+ // Attributes are not allowed between these keywords. Diagnose,
+ // but then just treat them like they appeared in the right place.
ProhibitAttributes(attrs);
- // Recovery: assume that the attributes came after the tag.
+
+ // They are allowed afterwards, though.
+ MaybeParseGNUAttributes(attrs);
MaybeParseCXX0XAttributes(attrs);
+ while (Tok.is(tok::kw___declspec))
+ ParseMicrosoftDeclSpec(attrs);
}
// C++11 [temp.explicit]p12:
diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp
index db5eebfaacf..a0b8467bcca 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -207,3 +207,8 @@ void baz () {
for ([[]] int n : { 1, 2, 3 }) {
}
}
+
+enum class __attribute__((visibility("hidden"))) SecretKeepers {
+ one, /* rest are deprecated */ two, three
+};
+enum class [[]] EvenMoreSecrets {};
OpenPOWER on IntegriCloud