[GCC, C23]
For some reason, it was not possible to place labels at the before declarations or at end of compound statements. One can work around this by placing a null statement after the label:
out: ;
}
This is only a minor syntactic isuse, but annoying (I run into it all the time and others do too, e.g. Stackoverflow)
void f(int x)
{
restart: // label not allowed before declaration
int z = 3 * x;
switch (x) {
case 1: // label not allowed before declaration
int y = z;
if (y == 3)
goto out;
if (y > z)
goto restart;
break;
default: // label not allowed at end of block
/* do nothing */
}
out: // label not allowed at end of block
}
The change for C also made the grammar simpler. A similar change will likely end up in C++ too (although in a way that makes it look like a special case in the grammar).
GCC: Commit