view gcc/testsuite/g++.dg/cet-notrack-1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line source

/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-fcf-protection" } */
/* { dg-final { scan-assembler "endbr32|endbr64" } } */
/* { dg-final { scan-assembler-times "\tcall\[ \t]+puts" 2 } } */
/* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */
#include <stdio.h>

struct A {
virtual int foo() __attribute__((nocf_check)) { return 42; }
};

struct B : A {
int foo() __attribute__((nocf_check)) { return 73; }
};

int main() {
B b;
A& a = b;
int (A::*amem) () __attribute__((nocf_check)) = &A::foo; // take address
if ((a.*amem)() == 73) // use the address
  printf("pass\n");
else
  printf("fail\n");
return 0;
}