<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/123064>123064</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang's -Wunreachable-code does not fire if the first unreachable line is a macro
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nico
</td>
</tr>
</table>
<pre>
This warns (as it should):
```
thakis@Mac src % cat notreach.cc
[[noreturn]] void notreached();
void g();
void f() {
notreached();
g();
}
% clang -c notreach.cc -Wunreachable-code
notreach.cc:6:3: warning: code will never be executed [-Wunreachable-code]
6 | g();
| ^
1 warning generated.
```
This doesn't:
```
% cat notreach2.cc
[[noreturn]] void notreached();
void g();
#define MY_MACRO(x) (void)(x)
void f() {
notreached();
MY_MACRO(5);
g();
}
% clang -c notreach2.cc -Wunreachable-code
# no output
```
Not emitting unreachable code warnings for the macro itself probably makes sense, but the diagnostic disappearing completely seems surprising.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyslMFu4zYQhp9mdBnYkIamLR90UOL6lhYoChQ9FRQ5ktilSYOkspu3Lyh72yRN0MsKBCQN5-cM_4-gSslOnrkD-QDyVKklzyF23upQDcG8dL_NNuFXFX1CoFYltBnTHBZngI4geqjXsa_vo-7zrL7YBLv6SWlMUSOQRK0y-pAjKz1vtcaiKRUffIicl-hBnkCe8DlY808iG6B2LfMAdb9OTa8j34PjLYhwKNFP5PhOezjdWy_dOeUn3Og3LW5-X_z6owbHGx0MQ92_SgDR70H0AkS_GmT9VD5LIn61zqHnZ444MPI31ktmgyAfPlhVntb2EPcIh0d81yiuz20C5E9Q9833cjix56gym-07BlD3KzgTOHmgQ_6Q1Hsw9CPJAAnDo_WMT3_8-dQ__voLUPttxURtUZTkW-RzlJ-yfLWm_B_EH_GlTwEDCfQBw5KvS_6vqz-HjHyxORf7X8nv2G9cEo4hYp4ZL0rHgDYndiNeYxjU4F7wor5wwsQ-MdAjDktek41Vkw8pW43GJnW9soqljA6Xq-PM7gUT8yVhWuI12mT9tK1MJ8xRHFXFXXMQ-6MUJJpq7mgw7dHsGyJWRHticZS6qcd9OxglWq5sRzXJumlkI-taNNvDsWm53o27VqphkDvY1XxR1m2de75sQ5wqm9LCXUOi3u8qpwZ2ab03iFaDQfRjDD6zN0BUbpPYFe1mWKZyHzibcvp3tWyz4-6mpEP6AMd6fAszHG1ktONq02hjym-8d-WU2YTq5ne1RNfNOV9TOfV0BjpPNs_LsNXhAnQuHdxfm2sMf7HOQOd1cwnofN_fc0d_BwAA__8fU4v1">