Skip to content

Commit 6ce2e01

Browse files
committed
Add indirect goto test
1 parent 65cf824 commit 6ce2e01

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clang/test/Sema/warn-jump-bypasses-init.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@ void f(void) {
4545
ouch:
4646
;
4747
}
48+
49+
void indirect(int n) {
50+
DirectJump:
51+
;
52+
53+
void *Table[] = {&&DirectJump, &&Later};
54+
goto *Table[n]; // c-warning {{jump from this indirect goto statement to one of its possible targets is incompatible with C++}} \
55+
cxx-error {{cannot jump from this indirect goto statement to one of its possible targets}}
56+
57+
int x = 12; // both-note {{jump bypasses variable initialization}}
58+
Later: // both-note {{possible target of indirect goto statement}}
59+
;
60+
}

0 commit comments

Comments
 (0)