llvm-project
62176b16 - [clang][Sema] Do not warn about predefined identifiers outside a function in unevaluated operands (#248329)

Commit
1 day ago
[clang][Sema] Do not warn about predefined identifiers outside a function in unevaluated operands (#248329) Clang warns about `__func__`, `__FUNCTION__` and `__PRETTY_FUNCTION__` outside a function even when the name is in an unevaluated operand, where it is never used. glibc's `assert/tst-assert-c++.cc` has this at namespace scope: ```cpp static_assert(is_void <decltype (assert (""))>::value, "type is void"); ``` `assert()` uses `__PRETTY_FUNCTION__`, so the test fails to build with `-Werror`. Do not emit `-Wpredefined-identifier-outside-function` in an unevaluated operand such as `sizeof`, `decltype`, `typeof` or `noexcept`. Do the same for the Microsoft string literal expansion of `__FUNCTION__` and friends (`"" __FUNCTION__`). A use that is evaluated still warns. Assisted-by: Claude Opus 5.5
Author
Parents
Loading