Merge to HEAD at tree-cleanup-merge-20041024 .
[official-gcc.git] / gcc / testsuite / gcc.misc-tests / gcov-3.c
blobfcccdeeff419575a95764c5ad54714c8582fc595
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 extern void abort (void);
8 extern void exit (int);
10 int expect_do1 = 1, expect_do2 = 2;
12 static int doit(int x){
13 __label__ lbl1;
14 __label__ lbl2;
15 static int jtab_init = 0;
16 static void *jtab[2];
18 if(!jtab_init) {
19 jtab[0] = &&lbl1;
20 jtab[1] = &&lbl2;
21 jtab_init = 1;
23 goto *jtab[x];
24 lbl1:
25 return 1;
26 lbl2:
27 return 2;
30 static void do1(void) {
31 if (doit(0) != expect_do1)
32 abort ();
35 static void do2(void){
36 if (doit(1) != expect_do2)
37 abort ();
40 int main(void){ /* count(1) */
41 #ifndef NO_LABEL_VALUES
42 do1();
43 do2();
44 #endif
45 exit(0); /* count(1) */
48 /* { dg-final { run-gcov gcov-3.c } } */