aboutsummaryrefslogtreecommitdiff
path: root/test/cfi/cross-dso/icall/icall-from-dso.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/cfi/cross-dso/icall/icall-from-dso.cpp')
-rw-r--r--test/cfi/cross-dso/icall/icall-from-dso.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/cfi/cross-dso/icall/icall-from-dso.cpp b/test/cfi/cross-dso/icall/icall-from-dso.cpp
new file mode 100644
index 000000000000..1995f05f43d4
--- /dev/null
+++ b/test/cfi/cross-dso/icall/icall-from-dso.cpp
@@ -0,0 +1,26 @@
+// RUN: %clangxx_cfi_dso -DSHARED_LIB %s -fPIC -shared -o %t-so.so
+// RUN: %clangxx_cfi_dso %s -o %t %t-so.so && %expect_crash %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+
+#ifdef SHARED_LIB
+void g();
+void f() {
+ // CHECK: =1=
+ fprintf(stderr, "=1=\n");
+ ((void (*)(void))g)();
+ // CHECK: =2=
+ fprintf(stderr, "=2=\n");
+ ((void (*)(int))g)(42); // UB here
+ // CHECK-NOT: =3=
+ fprintf(stderr, "=3=\n");
+}
+#else
+void f();
+void g() {
+}
+
+int main() {
+ f();
+}
+#endif