From 923627f030ae1cabd7245b186dc5ee41181fc951 Mon Sep 17 00:00:00 2001 From: bellard Date: Sun, 3 Nov 2002 00:44:07 +0000 Subject: [PATCH] computed goto test --- tcctest.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tcctest.c b/tcctest.c index 77027d1..64258ad 100644 --- a/tcctest.c +++ b/tcctest.c @@ -325,6 +325,7 @@ void loop_test() void goto_test() { int i; + static void *label_table[3] = { &&label1, &&label2, &&label3 }; printf("goto:\n"); i = 0; @@ -336,6 +337,20 @@ void goto_test() goto s_loop; s_end: printf("\n"); + + /* we also test computed gotos (GCC extension) */ + for(i=0;i<3;i++) { + goto *label_table[i]; + label1: + printf("label1\n"); + goto next; + label2: + printf("label2\n"); + goto next; + label3: + printf("label3\n"); + next: ; + } } enum {