[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / asan / TestCases / throw_call_test.cpp
blob20a7c0b7660155102bb8fac142b6b9ce7cc58306
1 // RUN: %clangxx_asan %s -o %t && %run %t
2 // http://code.google.com/p/address-sanitizer/issues/detail?id=147 (not fixed).
3 // BROKEN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t
5 #include <stdio.h>
6 static volatile int zero = 0;
7 inline void pretend_to_do_something(void *x) {
8 __asm__ __volatile__("" : : "r" (x) : "memory");
11 __attribute__((noinline, no_sanitize_address))
12 void ReallyThrow() {
13 fprintf(stderr, "ReallyThrow\n");
14 if (zero == 0)
15 throw 42;
18 __attribute__((noinline))
19 void Throw() {
20 int a, b, c, d, e, f, g, h;
21 pretend_to_do_something(&a);
22 pretend_to_do_something(&b);
23 pretend_to_do_something(&c);
24 pretend_to_do_something(&d);
25 pretend_to_do_something(&e);
26 pretend_to_do_something(&f);
27 pretend_to_do_something(&g);
28 pretend_to_do_something(&h);
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 fprintf(stderr, "CheckStack stack = %p, %p\n", ar, ar + 100);
38 for (int i = 0; i < 100; i++)
39 ar[i] = i;
42 int main(int argc, char** argv) {
43 try {
44 Throw();
45 } catch(int a) {
46 fprintf(stderr, "a = %d\n", a);
48 CheckStack();