[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / asan / TestCases / throw_invoke_test.cpp
bloba9069e1ca8d1a5ab074c87d30d63b32b6e2076a8
1 // RUN: %clangxx_asan %s -o %t && %run %t
2 // RUN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t
4 // Investigate why it fails with NDK 21.
5 // UNSUPPORTED: android
7 #include <stdio.h>
8 static volatile int zero = 0;
9 inline void pretend_to_do_something(void *x) {
10 __asm__ __volatile__("" : : "r" (x) : "memory");
13 __attribute__((noinline))
14 void ReallyThrow() {
15 fprintf(stderr, "ReallyThrow\n");
16 try {
17 if (zero == 0)
18 throw 42;
19 else if (zero == 1)
20 throw 1.;
21 } catch(double x) {
25 __attribute__((noinline))
26 void Throw() {
27 int a, b, c, d, e;
28 pretend_to_do_something(&a);
29 pretend_to_do_something(&b);
30 pretend_to_do_something(&c);
31 pretend_to_do_something(&d);
32 pretend_to_do_something(&e);
33 fprintf(stderr, "Throw stack = %p\n", &a);
34 ReallyThrow();
37 __attribute__((noinline))
38 void CheckStack() {
39 int ar[100];
40 pretend_to_do_something(ar);
41 for (int i = 0; i < 100; i++)
42 ar[i] = i;
43 fprintf(stderr, "CheckStack stack = %p, %p\n", ar, ar + 100);
46 int main(int argc, char** argv) {
47 try {
48 Throw();
49 } catch(int a) {
50 fprintf(stderr, "a = %d\n", a);
52 CheckStack();