Debian Codegraph @

gcc/testsuite/gcc.target/i386/cet-switch-3.c

raw
1 /* Verify that CET works. */
2 /* { dg-do compile } */
3 /* { dg-options "-O -fcf-protection -mcet-switch" } */
4 /* { dg-final { scan-assembler-times "endbr32" 12 { target ia32 } } } */
5 /* { dg-final { scan-assembler-times "endbr64" 12 { target { ! ia32 } } } } */
6 /* { dg-final { scan-assembler-times "\[ \t]+jmp\[ \t]+\[*]" 1 } } */
7
8 void func2 (int);
9
10 __attribute__ ((noinline, noclone))
11 static int
12 func1 (int arg)
13 {
14 switch (arg)
15 {
16 case 1: func2 (arg*100);
17 case 2: func2 (arg*300);
18 case 5: func2 (arg*500);
19 case 8: func2 (arg*700);
20 case 7: func2 (arg*900);
21 case -1: func2 (arg*-100);
22 case -2: func2 (arg*-300);
23 case -5: func2 (arg*-500);
24 case -7: func2 (arg*-700);
25 case -9: func2 (arg*-900);
26 }
27 return 0;
28 }
29
30 int
31 foo (int arg)
32 {
33 return func1 (arg);
34 }