From 688761409155b47c39eb5dae1b8c6c8a9f43307a Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 30 Jul 2011 07:01:49 +0000 Subject: [PATCH] Turn off __has_feature(is_empty) and __has_feature(is_pod) if the libstdc++ hack has reverted these type traits to keywords. Icky, but fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136560 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/PPMacroExpansion.cpp | 6 ++++-- lib/Parse/ParseDeclCXX.cpp | 2 +- test/SemaCXX/libstdcxx_is_pod_hack.cpp | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 5a88e5ff98..58ba42e49a 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -639,11 +639,13 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .Case("is_base_of", LangOpts.CPlusPlus) .Case("is_class", LangOpts.CPlusPlus) .Case("is_convertible_to", LangOpts.CPlusPlus) - .Case("is_empty", LangOpts.CPlusPlus) + .Case("is_empty", + LangOpts.CPlusPlus && II->getTokenID() != tok::identifier) .Case("is_enum", LangOpts.CPlusPlus) .Case("is_literal", LangOpts.CPlusPlus) .Case("is_standard_layout", LangOpts.CPlusPlus) - .Case("is_pod", LangOpts.CPlusPlus) + .Case("is_pod", + LangOpts.CPlusPlus && II->getTokenID() != tok::identifier) .Case("is_polymorphic", LangOpts.CPlusPlus) .Case("is_trivial", LangOpts.CPlusPlus) .Case("is_trivially_copyable", LangOpts.CPlusPlus) diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 0da743f2a9..344a433792 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -901,7 +901,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, Tok.is(tok::kw___is_signed) || Tok.is(tok::kw___is_unsigned) || Tok.is(tok::kw___is_void))) { - // GNU libstdc++ 4.2 and libc++ uaw certain intrinsic names as the + // 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 diff --git a/test/SemaCXX/libstdcxx_is_pod_hack.cpp b/test/SemaCXX/libstdcxx_is_pod_hack.cpp index 3581c796ce..3ac233627c 100644 --- a/test/SemaCXX/libstdcxx_is_pod_hack.cpp +++ b/test/SemaCXX/libstdcxx_is_pod_hack.cpp @@ -27,3 +27,7 @@ struct test_is_signed { }; bool check_signed = test_is_signed::__is_signed; + +#if __has_feature(is_pod) +# error __is_pod won't work now anyway +#endif -- 2.40.0