Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/cet-notrack-1.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
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; }