Move MSan lit-tests under test/msan
[blocksruntime.git] / lib / asan / lit_tests / TestCases / throw_invoke_test.cc
blob077a940e8d19d4d85f696b776ab5179c6493b1bf
1 // RUN: %clangxx_asan %s -o %t && %t
2 // RUN: %clangxx_asan %s -o %t -static-libstdc++ && %t
3 #include <stdio.h>
4 static volatile int zero = 0;
5 inline void pretend_to_do_something(void *x) {
6 __asm__ __volatile__("" : : "r" (x) : "memory");
9 __attribute__((noinline))
10 void ReallyThrow() {
11 fprintf(stderr, "ReallyThrow\n");
12 try {
13 if (zero == 0)
14 throw 42;
15 else if (zero == 1)
16 throw 1.;
17 } catch(double x) {
21 __attribute__((noinline))
22 void Throw() {
23 int a, b, c, d, e;
24 pretend_to_do_something(&a);
25 pretend_to_do_something(&b);
26 pretend_to_do_something(&c);
27 pretend_to_do_something(&d);
28 pretend_to_do_something(&e);
29 fprintf(stderr, "Throw stack = %p\n", &a);
30 ReallyThrow();
33 __attribute__((noinline))
34 void CheckStack() {
35 int ar[100];
36 pretend_to_do_something(ar);
37 for (int i = 0; i < 100; i++)
38 ar[i] = i;
39 fprintf(stderr, "CheckStack stack = %p, %p\n", ar, ar + 100);
42 int main(int argc, char** argv) {
43 try {
44 Throw();
45 } catch(int a) {
46 fprintf(stderr, "a = %d\n", a);
48 CheckStack();