1 /* PR tree-optimization/79472 */
2 /* { dg-options "-O2 -fdump-tree-switchconv" } */
3 /* { dg-do compile { target nonpic } } */
4 
5 void
frobulate(unsigned int v)6 frobulate (unsigned int v)
7 {
8   const char *s;
9 
10   switch (v)
11     {
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       __builtin_abort ();
23       break;
24     }
25 
26   __builtin_printf ("%s\n", s);
27 }
28 
29 void
frobulate_for_gcc(unsigned int v)30 frobulate_for_gcc (unsigned int v)
31 {
32   const char *s;
33 
34   switch (v)
35     {
36     case 0:
37       s = "foo";
38       break;
39     case 1:
40       s = "bar";
41       break;
42     case 2:
43       s = "spam";
44       break;
45     default:
46       s = (const char *) 0;
47       break;
48     }
49 
50   if (!s)
51     __builtin_abort ();
52 
53   __builtin_printf ("%s\n", s);
54 }
55 
56 /* { dg-final { scan-tree-dump-times "Switch converted" 2 "switchconv" } } */
57 /* { dg-final { scan-tree-dump-times "= CSWTCH" 2 "switchconv" } } */
58