From 899022b14bc3bde19a949fb042711864ca3a629b Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 9 Jul 2013 00:57:56 +0000 Subject: [PATCH] Generalize hack allowing 'const' in __has_attribute (etc) to allow any token with identifier info. This covers most identifier-like entities (other than the ISO646 keywords). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185895 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/PPMacroExpansion.cpp | 4 +--- test/Preprocessor/has_attribute.c | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 06f14c24bd..d21515c5a6 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -1218,9 +1218,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { if (Tok.is(tok::l_paren)) { // Read the identifier LexUnexpandedToken(Tok); - if (Tok.is(tok::identifier) || Tok.is(tok::kw_const)) { - FeatureII = Tok.getIdentifierInfo(); - + if ((FeatureII = Tok.getIdentifierInfo())) { // Read the ')'. LexUnexpandedToken(Tok); if (Tok.is(tok::r_paren)) diff --git a/test/Preprocessor/has_attribute.c b/test/Preprocessor/has_attribute.c index 711cf671cf..555c2b3f9e 100644 --- a/test/Preprocessor/has_attribute.c +++ b/test/Preprocessor/has_attribute.c @@ -34,3 +34,7 @@ int has_something_we_dont_have(); static int constFunction() __attribute__((const)); #endif +// CHECK: has_no_volatile_attribute +#if !__has_attribute(volatile) +int has_no_volatile_attribute(); +#endif -- 2.40.0