Issue |
126398
|
Summary |
[Modules] `-Wembedded-directive` warning missing for pp-module in macro arguments
|
Labels |
clang:frontend,
clang:modules
|
Assignees |
|
Reporter |
hubert-reinterpretcast
|
The `-Wembedded-directive` warning is intended to identify the undefined behaviour specified in https://wg21.link/cpp.replace.general; however, it does not trigger for _pp-module_ (and likely other module-related forms of preprocessing directives).
A proposal (P2843) to require a diagnostic for such cases is before WG 21: https://github.com/cplusplus/papers/issues/1548
https://godbolt.org/z/seTaYE6nj
### Source (`<stdin>`)
```cpp
export module A;
#define A(X) # X
export char x[] = A(
module : private;
#if 0
#endif
);
```
### Compiler invocation
```
clang++ -fsyntax-only -std=c++20 -Wall -Wextra -pedantic -xc++ -
```
### Actual compiler output
```
<stdin>:6:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive]
6 | #if 0
| ^
1 warning generated.
```
### Expected compiler output
(warning also for line 5)
### Compiler version info (`clang++ -v`)
```
clang version 21.0.0git (https://github.com/llvm/llvm-project.git e6e8ac59ba45e03da92aebec1f4561c1fa970df1)
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