Any label referenced by a goto statement is declared in the same block, or in a block enclosing the goto statement
// Label [ $lname := @Id ] [ parent:: { * [ name() != 'CompoundStmt' ] / parent:: } CompoundStmt [ $container := this() ] / ancestor::FuncBody / descendant::GotoStmt [ @Label = $lname ] [ not ancestor::CompoundStmt [ this() = $container ] ] ]
1 void test6_6_1()
2 {
3
4 int j = 0;
5 goto L1;
6 for (j = 0; j < 10; ++j) L1: // MATCHES
7 j;
8 }
9
10 void test6_6_1x() {
11
12 int j = 0;
13 goto L2;
14 for (j = 0; j < 10; ++j)
15 {
16 L2:
17 j;
18 }
19 }