<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56040>56040</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang C compiler does not support declarations after a label
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ramonpantin
</td>
</tr>
</table>
<pre>
/*
$ clang --version
Debian clang version 13.0.1-3+build2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang -c -std=c17 clang-label-bug.c
clang-label-bug.c:5:8: error: expected expression
retry: int r = bar();
^
clang-label-bug.c:6:7: error: use of undeclared identifier 'r'
if (!r) goto retry;
^
clang-label-bug.c:7:9: error: use of undeclared identifier 'r'
return r;
^
3 errors generated.
$ clang -DWORK_AROUND -c -std=c17 clang-label-bug.c
$
*/
#ifndef WORK_AROUND
int bar();
int foo(int a) {
retry: int r = bar();
if (!r) goto retry;
return r;
}
#else
int bar();
int foo(int a) {
retry:; int r = bar(); /* Clang needs the extra ; after the retry: */
if (!r) goto retry;
return r;
}
#endif
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VNtunDAQ_RrzYoHALLcHHnZDI1WVGilq1cfIwMC68trINunm7zuGTbPJJmrUC5JhPDP4HM8Zu9X9Q03YNWFbEjck3hK2oZ3kaqRheA_GCq3WQAOt4OoUO0VokkZxlIQpYbt2FrJna-4XbkZwJN3SY5nf5Ztw6kIp1HwMRzWfUvYGeE8PugfpEydtxXENfVTWcSmhb4TxIaQ3W4PvVpy4XFDtaGhdT9KmS4rVF0reggzbeYy6Nf3SnW4zHKXHAGP0AgbHCToHvTcM2Kf9G3DmwWdQoRw1FMFoy5FWSVhF0t2aRU8PyT68jZrjKJ6hzhaoHuisesAfDMKLHpQTgwBEYgXCFM8BxEAX6ARDFR210_TE8AWT39PxVKq_pIPYs1HUvA5_RiBdUSwdQYHhWOnoQs3m283tp7vt7c3Xz837tMWfH42t7-ZnXZKKATcy0LNVzxO8nJdCeu-gNXq9xX2RSbH7k1Z4t1IXNSRF82InIC38G-6Y_Ab7M9GWe4FeLaoogN5Stwc8Gc5w6jP54LAhvO9XSc4F-C8VUL0Y1lnQ12lfpRUPnHAS6pXnFe30YRISifUaLFXaUTtPkzaOru3MHR5qeyLP6dJMwWxkvXdusr42ft_Xo3D7uY1wNZxIef_4CSejv-MdgVNh7QwWjSyPN3Gwr6sq20BSDSwdSjZkZZq2Q1626QaKdmBJEixgtibZjjCm4AddlkCbZE0gahYzFufJhiVxyapoyOI4z3nVVjyHgpdkE8OBCxl5HpE2Y2DqhRIeBYtBKayzT0GO19eIui1wuD6f3V6b2vCDVhPH86yCBb5e6P8ENbW7pA">