[clang] [Clang] prevent preprocessor crash on incomplete scoped __has_cpp_attribute arguments (PR #178273)

Oleksandr Tarasiuk via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 28 04:53:00 PST 2026


================
@@ -14,3 +14,13 @@ __has_cpp_attribute(__clang__::fallthrough) // expected-error {{missing ')' afte
                                             // expected-note {{to match this '('}} \
                                             // expected-error {{builtin feature check macro requires a parenthesized identifier}}
 
+namespace GH178098 {
+// expected-error at +2 {{builtin feature check macro requires a parenthesized identifier}}
+// expected-error at +1 {{expected value in expression}}
+#if __has_cpp_attribute(clang::
----------------
a-tarasyuk wrote:

@AaronBallman thanks for the feedback. I’ve added tests for `__has_c_attribute` and `__has_attribute`., `__has_include` already has coverage for these cases

https://github.com/llvm/llvm-project/blob/7c3a2113febd1df48b31c2ada5cbcf1935053807/clang/test/Preprocessor/has_include.c#L155-L172

https://github.com/llvm/llvm-project/pull/178273


More information about the cfe-commits mailing list