<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92775>92775</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang accepts declaration in a statement other than a compound statement
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c,
regression,
accepts-invalid,
confirmed
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
The following code is grammatically incorrect:
```
void func() {
if (1)
int x;
}
```
because an iteratation statement must be followed by a secondary-block, which is a kind of statement, which does not accept declarations accept as allowed by compound-statement. GCC properly rejects this code as did Clang 17, so this is a recent regression: https://godbolt.org/z/sj3de1T74
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsUt1uszoQfBpzs0oE5v-CizQR5wX6Aou9gFtjR17TnpynP4IkTfXpk5AQM2hmZ3aR2UyOqBPlmygvCa5x9qE7YfDuDa1d0CWD17fufSYYvbX-27gJlNcEhmEKuCwYjUJrb2Cc8iGQiiI_ifQi0pOo0sezf355o2FcnRKyEbIFUb_dCQAzgpBNJmT7RACMi_CvyB__iPryV9GBFK5MgA5MpIARo_EOOGKkhVyEZeUIw3N80jDcAIFJeacx3A6D9epTyDN8z0bNWyyET-M0-PGl8uK1JwbnI6BSdI2gSVkMuyk_MWTAl5nyy9WvTh9-1I7wz_kM1-CvFOwNAn2QigxxNnzvFhm00XC26CbI6s2d_Z3f5wuktmiBpkDMxjuRn2CO8cpb97IXsp-8HryNRx8mIfv_hOz5I9eUvddFortct3mLCXVZnVUya9u8SeZOZXldDaqlqs6qsmjTsSzyKtdpU6dpPaSJ6WQqi7SUaVYWZd4c66qpJKpmrGVbtVkpipQWNPZo7deyeSeGeaWulXVdJhYHsrwfm5RKSCnkWUj5K8YTuhfJB-O-0Br9gyvvRhMW2pHykoRuMzoM68SiSK3hyC_raKKl7l7iQ_D3usC47RB-DsXHmQLEGTf4ubQXn6zBdn90bOK8DkflFyH7zfbxOlyD31YqZL_HZyH7vYH_AwAA___dEBwE">