1// RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
2// RUN: %clangxx_asan -m64 -O1 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
3// RUN: %clangxx_asan -m64 -O2 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
4// RUN: %clangxx_asan -m64 -O3 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
5// RUN: %clangxx_asan -m32 -O0 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
6// RUN: %clangxx_asan -m32 -O1 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
7// RUN: %clangxx_asan -m32 -O2 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
8// RUN: %clangxx_asan -m32 -O3 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
9
10// CHECK: AddressSanitizer: global-buffer-overflow
11int global[10];
12// CHECK: {{#0.*call4}}
13void __attribute__((noinline)) call4(int i) { global[i+10]++; }
14// CHECK: {{#1.*call3}}
15void __attribute__((noinline)) call3(int i) { call4(i); }
16// CHECK: {{#2.*call2}}
17void __attribute__((noinline)) call2(int i) { call3(i); }
18// CHECK: {{#3.*call1}}
19void __attribute__((noinline)) call1(int i) { call2(i); }
20// CHECK: {{#4.*main}}
21int main(int argc, char **argv) {
22  call1(argc);
23  return global[0];
24}
25