summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/cet-label-2.c
blob: c7f79819079b65a907ac311bd80e0802c8f7fdf5 (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
/* Verify that CET works.  */
/* { dg-do compile } */
/* { dg-options "-O -fcf-protection -mcet" } */
/* { dg-final { scan-assembler-times "endbr32" 3 { target ia32 } } } */
/* { dg-final { scan-assembler-times "endbr64" 3 { target { ! ia32 } } } } */

__attribute__ ((noinline, noclone))
static int
func (int arg)
{
  static void *array[] = { &&foo, &&bar };

  goto *array[arg];
foo:
  return arg*111;
bar:
  return arg*777;
}

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