Open
Description
Clang does not use the header-name grammar (https://eel.is/c++draft/lex.header#nt:header-name) when parsing the quoted form of header name. Instead, it appears to accept string literals in place of a header name.
Clang fails to accept the following; GCC, EDG, and MSVC all accept (https://godbolt.org/z/ThaPrv9e9):
#if __has_include("\")
#endif
Source (<stdin>
)
(as above)
Compiler invocation
clang++ -fsyntax-only -std=c++26 -xc++ -
Actual compiler output
<stdin>:1:19: warning: missing terminating '"' character [-Winvalid-pp-token]
1 | #if __has_include("\")
| ^
<stdin>:1:19: error: expected "FILENAME" or <FILENAME>
<stdin>:1:19: error: invalid token at start of a preprocessor expression
1 warning and 2 errors generated.
Expected compiler output
(clean compile)
Compiler version info (clang++ -v
)
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 41b572b99cd5f222330effa323af9c4da8d73e10)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Candidate multilib: .;@m64
Selected multilib: .;@m64