Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / cswtch-5.c
blob319e565d9d0a28d20dd680b98037fe1861b80153
1 /* PR tree-optimization/79472 */
2 /* { dg-options "-O2 -fdump-tree-switchconv" } */
3 /* { dg-do compile { target nonpic } } */
5 void
6 foo (unsigned int v)
8 const char *s;
10 switch (v)
12 case 0:
13 s = "foo";
14 break;
15 case 1:
16 s = "bar";
17 break;
18 case 2:
19 s = "spam";
20 break;
21 default:
22 for (int i = 0; i < v; i++)
23 __builtin_printf ("baz\n");
24 return;
27 __builtin_printf ("%s\n", s);
30 int
31 bar (unsigned int v, int w)
33 const char *s;
35 switch (v)
37 case 0:
38 s = "foo";
39 break;
40 case 1:
41 s = "bar";
42 break;
43 case 2:
44 s = "spam";
45 break;
46 default:
47 __builtin_printf ("baz\n");
48 if (v > 25)
49 __builtin_printf ("bl1\n");
50 else
51 __builtin_printf ("bl2\n");
52 goto lab;
55 __builtin_printf ("%s\n", s);
56 if (w > 25)
57 __builtin_printf ("cl1\n");
58 else
59 __builtin_printf ("cl2\n");
60 lab:
61 __builtin_printf ("dl\n");
62 return v + w;
65 /* { dg-final { scan-tree-dump-times "Switch converted" 2 "switchconv" } } */
66 /* { dg-final { scan-tree-dump-times "= CSWTCH" 2 "switchconv" } } */