Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / cfi / target_uninstrumented.cpp
blob8543fdae1446ce2a35a1e50582d8e62285fbd6de
1 // RUN: %clangxx -g -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
2 // RUN: %clangxx_cfi_diag -g %s -o %t %ld_flags_rpath_exe
3 // RUN: %run %t 2>&1 | FileCheck %s
5 // REQUIRES: cxxabi
6 // UNSUPPORTED: target={{.*windows-msvc.*}}
8 #include <stdio.h>
9 #include <string.h>
11 struct A {
12 virtual void f();
15 void *create_B();
17 #ifdef SHARED_LIB
19 struct B {
20 virtual void f();
22 void B::f() {}
24 void *create_B() {
25 return (void *)(new B());
28 #else
30 void A::f() {}
32 int main(int argc, char *argv[]) {
33 void *p = create_B();
34 // CHECK: runtime error: control flow integrity check for type 'A' failed during cast to unrelated type
35 // CHECK: invalid vtable
36 // CHECK: check failed in {{.*}}, vtable located in {{.*}}libtarget_uninstrumented.cpp.dynamic.so
37 A *a = (A *)p;
38 memset(p, 0, sizeof(A));
40 // CHECK: runtime error: control flow integrity check for type 'A' failed during cast to unrelated type
41 // CHECK: invalid vtable
42 // CHECK: check failed in {{.*}}, vtable located in (unknown)
43 a = (A *)p;
44 // CHECK: done
45 fprintf(stderr, "done %p\n", a);
47 #endif