/cp
[official-gcc.git] / gcc / testsuite / g++.dg / cet-notrack-1.C
blobeab0946d4779ed0351421500fcc5e4f117966a52
1 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-fcf-protection" } */
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>
8 struct A {
9 virtual int foo() __attribute__((nocf_check)) { return 42; }
12 struct B : A {
13 int foo() __attribute__((nocf_check)) { return 73; }
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;