2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.misc-tests / gcov-3.c
blob36fe64f802b1862d2db78efeea0f0d6d882dd5f7
1 /* Test Gcov with computed gotos.
2 This is the same as test gcc.c-torture/execute/980526-1.c */
4 /* { dg-options "-fprofile-arcs -ftest-coverage" } */
5 /* { dg-do run { target native } } */
7 int expect_do1 = 1, expect_do2 = 2;
9 static int doit(int x){
10 __label__ lbl1;
11 __label__ lbl2;
12 static int jtab_init = 0;
13 static void *jtab[2];
15 if(!jtab_init) {
16 jtab[0] = &&lbl1;
17 jtab[1] = &&lbl2;
18 jtab_init = 1;
20 goto *jtab[x];
21 lbl1:
22 return 1;
23 lbl2:
24 return 2;
27 static void do1(void) {
28 if (doit(0) != expect_do1)
29 abort ();
32 static void do2(void){
33 if (doit(1) != expect_do2)
34 abort ();
37 int main(void){ /* count(1) */
38 #ifndef NO_LABEL_VALUES
39 do1();
40 do2();
41 #endif
42 exit(0); /* count(1) */
45 /* { dg-final { run-gcov gcov-3.c } } */