Files
llvm-project/clang/test/Preprocessor/has_c_attribute_errors.c
Oleksandr Tarasiuk bf7e2b81e7 [Clang] prevent preprocessor crash on incomplete scoped __has_cpp_attribute arguments (#178273)
Fixes #178098

---

This patch addressed the issue when `__has_cpp_attribute` is expanded
with incomplete scoped attributes. The scoped name parsing can lex to
`eof`/`eod` at


3f5a5d45d1/clang/lib/Lex/PPMacroExpansion.cpp (L1877-L1881)

and then proceed with


3f5a5d45d1/clang/lib/Lex/PPMacroExpansion.cpp (L1425-L1430)


since `eof`/`eod` is not guarded at


3f5a5d45d1/clang/lib/Lex/PPMacroExpansion.cpp (L1367-L1372)

this could lead to a preprocessor crash


3f5a5d45d1/clang/lib/Lex/PPMacroExpansion.cpp (L1370)
2026-01-28 15:44:48 +02:00

10 lines
363 B
C

// RUN: %clang_cc1 -triple i386-unknown-unknown -Eonly -verify %s
// expected-error@+2 {{builtin feature check macro requires a parenthesized identifier}}
// expected-error@+1 {{expected value in expression}}
#if __has_c_attribute(clang::
#endif
// expected-error@+1 {{builtin feature check macro requires a parenthesized identifier}}
__has_c_attribute(clang::