History

computed goto test

bellard committed 24 years ago

Commit 923627f1 parent 804d0c81 file · +15 −0Browse files

Unified · Split

tcctest.c+15−0
@@ -325,6 +325,7 @@ void loop_test() · 324 unmodified lines
325325 void goto_test()
326326 {
327327 int i;
328+ static void *label_table[3] = { &&label1, &&label2, &&label3 };
328329
329330 printf("goto:\n");
330331 i = 0;
@@ -336,6 +337,20 @@ void goto_test() · 5 unmodified lines
336337 goto s_loop;
337338 s_end:
338339 printf("\n");
340+
341+ /* we also test computed gotos (GCC extension) */
342+ for(i=0;i<3;i++) {
343+ goto *label_table[i];
344+ label1:
345+ printf("label1\n");
346+ goto next;
347+ label2:
348+ printf("label2\n");
349+ goto next;
350+ label3:
351+ printf("label3\n");
352+ next: ;
353+ }
339354 }
340355
341356 enum {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t