Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / safe-indirect-jump-5.c
blobfd04ffd56c7b3dc017a7381243dccfcc6b7edda8
1 /* { dg-do run } */
2 /* { dg-additional-options "-mno-speculate-indirect-jumps -Wno-pedantic" } */
3 /* { dg-warning "'-mno-speculate-indirect-jumps' is deprecated" "" { target *-*-* } 0 } */
5 /* Test for deliberate misprediction of computed goto. */
7 int __attribute__((noinline)) bar (int i)
9 return 1960 + i;
12 int __attribute__((noinline)) baz (int i)
14 return i * i;
17 int __attribute__((noinline)) spaz (int i)
19 return i + 1;
22 int foo (int x)
24 static void *labptr[] = { &&lab0, &&lab1, &&lab2 };
26 if (x < 0 || x > 2)
27 return -1;
29 goto *labptr[x];
31 lab0:
32 return bar (x);
34 lab1:
35 return baz (x) + 1;
37 lab2:
38 return spaz (x) / 2;
41 int main ()
43 if (foo (0) != 1960)
44 __builtin_abort ();
46 if (foo (1) != 2)
47 __builtin_abort ();
49 if (foo (2) != 1)
50 __builtin_abort ();
52 if (foo (3) != -1)
53 __builtin_abort ();
55 return 0;