brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1022 B · fb6e2f2 Raw
55 lines · cpp
1// XFAIL: *2 3// RUN: %clangxx_cfi -o %t1 %s4// RUN: %expect_crash %run %t1 2>&1 | FileCheck --check-prefix=CFI %s5 6// RUN: %clangxx_cfi -DB32 -o %t2 %s7// RUN: %expect_crash %run %t2 2>&1 | FileCheck --check-prefix=CFI %s8 9// RUN: %clangxx_cfi -DB64 -o %t3 %s10// RUN: %expect_crash %run %t3 2>&1 | FileCheck --check-prefix=CFI %s11 12// RUN: %clangxx_cfi -DBM -o %t4 %s13// RUN: %expect_crash %run %t4 2>&1 | FileCheck --check-prefix=CFI %s14 15// RUN: %clangxx -o %t5 %s16// RUN: %run %t5 2>&1 | FileCheck --check-prefix=NCFI %s17 18// Tests that the CFI enforcement distinguishes between non-overriding siblings.19// XFAILed as not implemented yet.20 21#include <stdio.h>22#include "utils.h"23 24struct A {25  virtual void f();26};27 28void A::f() {}29 30struct B : A {31  virtual void f();32};33 34void B::f() {}35 36struct C : A {37};38 39int main() {40  create_derivers<B>();41 42  B *b = new B;43  break_optimization(b);44 45  // CFI: 146  // NCFI: 147  fprintf(stderr, "1\n");48 49  ((C *)b)->f(); // UB here50 51  // CFI-NOT: 252  // NCFI: 253  fprintf(stderr, "2\n");54}55