<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/161014>161014</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wdeclaration-after-statement dislikes _Static_assert
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Alcaro
</td>
</tr>
</table>
<pre>
```c
int foo(void)
{
_Static_assert(2+2 == 4, "");
int a = 2;
_Static_assert(2+2 == 4, "");
a += 2;
_Static_assert(2+2 == 4, "");
return a;
}
```
-xc -Wdeclaration-after-statement
https://godbolt.org/z/Ee4aPbcd9
Result: 1x `warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]`.
Expected: Since a succeeding _Static_assert does nothing, it's neither declaration nor code; therefore, omit the warning. Especially considering _Static_assert itself is incompatible with standards before C99.
Found it at winehq, they're using that warning to enforce their coding style. https://gitlab.winehq.org/wine/wine/-/merge_requests/9061#note_116902
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyslMuO47YShp-mtCnYkErWbaGF3W6tD84ssmxQZNliQpMestSXPH1A24OeTIJBEAQgTLiuX_0lSaVkz555hOYAzbFQqywhjnunVQzFHMzHCG15PxrKvfWCpxCA-tdgDdAA5R66A5R7RMSXL6LE6heVEkcB6gnoQAj1Eeoj7oCeEIhuZ4D6W1auqXIQ0qfx35VSCHT4TypFljV6VHcLdMf8-00JKPebd42bXwxrp6ISG_xGnYTjJokSvrCXHF_uF5FrgnoPNAFN52Dm4GQb4hlo-h1oeuad-t-szXAP_z-n1QnUe6zeEdryTUVv_TkbLvbd-jN-1zGh8gZ1MIw2ofU6XK5K7OwY36wsmER5o6JJOPMpRManYUBoDj_Hbo7Qlts7zvP7lbWwyf2_WK8ZFaZVa2aTWf6sLJrACX2QJRPTE1oB6hJ6trJw_J4cfYg3cKgPmJ03vpwTLlayBR-Tb_E5XVlb5dwH6uCTNRz_preVxO70z3V4DDiF1Ru0gkrwzXpevmYIWfgDqIuMa8q9ZMnuOxBKQPanEDXnOHubI9uTfDje4g8Lt-LUvL2Xfqw9__m8NkDTheOZXyJ_XTlJApqGsq2Aah-EX6qqHUoqzFiboR5UwWPVNf0wVD01xTLu2qqrq77aVbrRXd-3Xb3b9U1TtnXPbacLO1JJTTlQV7VNSc22Geaams4YmqvT3BDsSr4o67bOvV4yY2FTWnms2qqsdoVTM7t0-z4QeX7Dmze_Ls2xiGNO2szrOcGudDZJ-iwjVhyPP33a0Njk7G-cfthnsUY3_kXKZZ23OlyAptzjcW2uMfzKWoCmG1nW74H-OtIfAQAA__-JLIiB">