Issue |
132643
|
Summary |
Clang parses header names incorrectly as strings
|
Labels |
clang:frontend,
accepts-invalid,
rejects-valid,
diverges-from:gcc,
diverges-from:msvc,
diverges-from:edg
|
Assignees |
|
Reporter |
hubert-reinterpretcast
|
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):
```cpp
#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
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs