Unified · Split
| @@ -325,6 +325,7 @@ void loop_test() · 324 unmodified lines | ||
| 325 | 325 | void goto_test() |
| 326 | 326 | { |
| 327 | 327 | int i; |
| 328 | + static void *label_table[3] = { &&label1, &&label2, &&label3 }; | |
| 328 | 329 | |
| 329 | 330 | printf("goto:\n"); |
| 330 | 331 | i = 0; |
| @@ -336,6 +337,20 @@ void goto_test() · 5 unmodified lines | ||
| 336 | 337 | goto s_loop; |
| 337 | 338 | s_end: |
| 338 | 339 | 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 | + } | |
| 339 | 354 | } |
| 340 | 355 | |
| 341 | 356 | enum { |