<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/126398>126398</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Modules] `-Wembedded-directive` warning missing for pp-module in macro arguments
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
clang:modules
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hubert-reinterpretcast
</td>
</tr>
</table>
<pre>
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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVVFv2zYQ_jX0y0ECRUqK9eAHxYmLPQwY0ALpngqKPElsaVIjKcfZrx8o2U6bdh2GLVAQRuR9uu_4fXciBD1YxB2p7kn1sBFzHJ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