diff options
author | Alp Toker <alp@nuanti.com> | 2013-12-17 14:12:30 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-12-17 14:12:30 +0000 |
commit | 53358e43bc71dc1d1660a26f8a403c8a2d6ed76b (patch) | |
tree | 56e6295fbc10aea6d548a98ca5dbcc0b531b8659 /clang/lib/Parse/ParseDeclCXX.cpp | |
parent | 8fb00b0f79feae2b63657f0ac3a1207b262120b2 (diff) | |
download | bcm5719-llvm-53358e43bc71dc1d1660a26f8a403c8a2d6ed76b.tar.gz bcm5719-llvm-53358e43bc71dc1d1660a26f8a403c8a2d6ed76b.zip |
Simplify RevertibleTypeTraits as a form of contextual keyword
Now that we emit diagnostics for keyword-as-identifier hacks (-Wkeyword-compat)
we can go ahead and simplify some of the old revertible keyword support.
This commit adds a TryIdentKeywordUpgrade() function to mirror the recently
added TryKeywordIdentFallback() and uses it to replace the hard-coded list of
REVERTIBLE_TYPE_TRAITs.
llvm-svn: 197496
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index b34b1119af9..2d6523cfe41 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1180,31 +1180,17 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // C++11 attributes SourceLocation AttrFixitLoc = Tok.getLocation(); - if (TagType == DeclSpec::TST_struct && - !Tok.is(tok::identifier) && - Tok.getIdentifierInfo() && - (Tok.is(tok::kw___is_arithmetic) || - Tok.is(tok::kw___is_convertible) || - Tok.is(tok::kw___is_empty) || - Tok.is(tok::kw___is_floating_point) || - Tok.is(tok::kw___is_function) || - Tok.is(tok::kw___is_fundamental) || - Tok.is(tok::kw___is_integral) || - Tok.is(tok::kw___is_member_function_pointer) || - Tok.is(tok::kw___is_member_pointer) || - Tok.is(tok::kw___is_pod) || - Tok.is(tok::kw___is_pointer) || - Tok.is(tok::kw___is_same) || - Tok.is(tok::kw___is_scalar) || - Tok.is(tok::kw___is_signed) || - Tok.is(tok::kw___is_unsigned) || - Tok.is(tok::kw___is_void))) - // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the - // name of struct templates, but some are keywords in GCC >= 4.3 - // and Clang. Therefore, when we see the token sequence "struct - // X", make X into a normal identifier rather than a keyword, to - // allow libstdc++ 4.2 and libc++ to work properly. - TryKeywordIdentFallback(true); + // GNU libstdc++ and libc++ use certain intrinsic names as the + // name of struct templates, but some are keywords in GCC >= 4.3 + // MSVC and Clang. For compatibility, convert the token to an identifier + // and issue a warning diagnostic. + if (TagType == DeclSpec::TST_struct && !Tok.is(tok::identifier) && + !Tok.isAnnotation()) { + const IdentifierInfo *II = Tok.getIdentifierInfo(); + // We rarely end up here so the following check is efficient. + if (II && II->getName().startswith("__is_")) + TryKeywordIdentFallback(true); + } // Parse the (optional) nested-name-specifier. CXXScopeSpec &SS = DS.getTypeSpecScope(); |