aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/cet-switch-3.c
blob: 0d9ed4488dd53ef0c4b37da6ffe8704ea649dac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Verify that CET works.  */
/* { dg-do compile } */
/* { dg-options "-O -fcf-protection -mcet-switch" } */
/* { dg-final { scan-assembler-times "endbr32" 12 { target ia32 } } } */
/* { dg-final { scan-assembler-times "endbr64" 12 { target { ! ia32 } } } } */
/* { dg-final { scan-assembler-times "\[ \t]+jmp\[ \t]+\[*]" 1 } } */

void func2 (int);

__attribute__ ((noinline, noclone))
static int
func1 (int arg)
{
  switch (arg)
  {
    case 1: func2 (arg*100);
    case 2: func2 (arg*300);
    case 5: func2 (arg*500);
    case 8: func2 (arg*700);
    case 7: func2 (arg*900);
    case -1: func2 (arg*-100);
    case -2: func2 (arg*-300);
    case -5: func2 (arg*-500);
    case -7: func2 (arg*-700);
    case -9: func2 (arg*-900);
  }
  return 0;
}

int
foo (int arg)
{
  return func1 (arg);
}