aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/attr-nocf-check-3a.c
blob: 9924cdc80f023875c967752b93e01a80d9da76b4 (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
/* { dg-do compile } */
/* { dg-options "-fcf-protection" } */

int  foo (void) __attribute__ ((nocf_check));
void (*foo1) (void) __attribute__((nocf_check));
void (*foo2) (void);

int __attribute__ ((nocf_check))
foo (void) /* The function's address is not tracked.  */
{
  /* This call site is not tracked for
     control-flow instrumentation.  */
  (*foo1)();

  foo1 = foo2; /* { dg-warning "incompatible pointer type" "" { target c } } */
	       /* { dg-error "invalid conversion" "" { target c++ } .-1 } */
  /* This call site is still not tracked for
     control-flow instrumentation.  */
  (*foo1)();

  /* This call site is tracked for
     control-flow instrumentation.  */
  (*foo2)();

  foo2 = foo1; /* { dg-warning "incompatible pointer type" "" { target c } } */
	       /* { dg-error "invalid conversion" "" { target c++ } .-1 } */
  /* This call site is still tracked for
     control-flow instrumentation.  */
  (*foo2)();

  return 0;
}