Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Linux / dlopen-mixed-c-cxx.c
blob05b55f9e3fcc2864416dcccdc7623274222c6442
1 // RUN: %clangxx_asan -xc++ -shared -fPIC -o %t.so - < %s
2 // RUN: %clang_asan %s -o %t.out -ldl
3 //
4 // RUN: { env ASAN_OPTIONS=verbosity=1 %t.out %t.so || : ; } 2>&1 | FileCheck %s
5 //
6 // CHECK: AddressSanitizer: failed to intercept '__cxa_throw'
7 //
8 // This tests assumes static linking of the asan runtime.
9 // UNSUPPORTED: asan-dynamic-runtime
11 #ifdef __cplusplus
13 static void foo(void) {
14 int i = 0;
15 throw(i);
18 extern "C" {
19 int bar(void);
21 int bar(void) {
22 try {
23 foo();
24 } catch (int i) {
25 return i;
27 return -1;
30 #else
32 #include <assert.h>
33 #include <dlfcn.h>
35 int main(int argc, char **argv) {
36 int (*bar)(void);
37 void *handle = dlopen(argv[1], RTLD_LAZY);
38 assert(handle);
39 bar = dlsym(handle, "bar");
40 assert(bar);
41 return bar();
44 #endif