111
|
1 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
|
131
|
2 /* { dg-options "-fcf-protection" } */
|
111
|
3 /* { dg-final { scan-assembler "endbr32|endbr64" } } */
|
|
4 /* { dg-final { scan-assembler-times "\tcall\[ \t]+puts" 2 } } */
|
|
5 /* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
|
|
6 #include <stdio.h>
|
|
7
|
|
8 struct A {
|
|
9 virtual int foo() __attribute__((nocf_check)) { return 42; }
|
|
10 };
|
|
11
|
|
12 struct B : A {
|
|
13 int foo() __attribute__((nocf_check)) { return 73; }
|
|
14 };
|
|
15
|
|
16 int main() {
|
|
17 B b;
|
|
18 A& a = b;
|
|
19 int (A::*amem) () __attribute__((nocf_check)) = &A::foo; // take address
|
|
20 if ((a.*amem)() == 73) // use the address
|
|
21 printf("pass\n");
|
|
22 else
|
|
23 printf("fail\n");
|
|
24 return 0;
|
|
25 }
|