OSDN Git Service

gcc/ada/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.misc-tests / bprob-2.c
1 /* Test profile-directed block ordering with computed gotos.
2  *
3    This is the same as test gcc.c-torture/execute/980526-1.c and
4    gcc.misc-tests/gcov-3.c */
5
6 extern void abort (void);
7 extern void exit (int);
8
9 int expect_do1 = 1, expect_do2 = 2;
10  
11 static int doit(int x){
12   __label__ lbl1;
13   __label__ lbl2;
14   static int jtab_init = 0;
15   static void *jtab[2];
16  
17   if(!jtab_init) {
18     jtab[0] = &&lbl1;
19     jtab[1] = &&lbl2;
20     jtab_init = 1;
21   }
22   goto *jtab[x];
23 lbl1:
24   return 1;
25 lbl2:
26   return 2;
27 }
28  
29 static void do1(void) {
30   if (doit(0) != expect_do1)
31     abort ();
32 }
33  
34 static void do2(void){
35   if (doit(1) != expect_do2)
36     abort ();
37 }
38  
39 int main(void){
40 #ifndef NO_LABEL_VALUES
41   do1();
42   do2();
43 #endif
44   exit(0);
45 }