diff options
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Preprocessor/has_attribute.c | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 5af0205af37..87a07a43d08 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -283,7 +283,11 @@ void Preprocessor::RegisterBuiltinMacros() { Ident_Pragma = RegisterBuiltinMacro(*this, "_Pragma"); // C++ Standing Document Extensions. - Ident__has_cpp_attribute = RegisterBuiltinMacro(*this, "__has_cpp_attribute"); + if (LangOpts.CPlusPlus) + Ident__has_cpp_attribute = + RegisterBuiltinMacro(*this, "__has_cpp_attribute"); + else + Ident__has_cpp_attribute = nullptr; // GCC Extensions. Ident__BASE_FILE__ = RegisterBuiltinMacro(*this, "__BASE_FILE__"); diff --git a/clang/test/Preprocessor/has_attribute.c b/clang/test/Preprocessor/has_attribute.c index 0ef5b4857a3..1a3c2a0e18c 100644 --- a/clang/test/Preprocessor/has_attribute.c +++ b/clang/test/Preprocessor/has_attribute.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple arm-unknown-linux -E %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple arm-unknown-linux -verify -E %s -o - | FileCheck %s // CHECK: always_inline #if __has_attribute(always_inline) @@ -53,3 +53,6 @@ int has_no_volatile_attribute(); #if !__has_attribute(uuid) int does_not_have_uuid #endif + +#if __has_cpp_attribute(selectany) // expected-error {{token is not a valid binary operator in a preprocessor subexpression}} +#endif |

