1// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
2// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
3// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
4// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
5
6__attribute__((noinline))
7static void NullDeref(int *ptr) {
8  // CHECK: ERROR: AddressSanitizer: SEGV on unknown address
9  // CHECK:   {{0x0*000.. .*pc 0x.*}}
10  ptr[10]++;  // BOOM
11  // atos on Mac cannot extract the symbol name correctly.
12  // CHECK-Linux: {{    #0 0x.* in NullDeref.*null_deref.cc:}}[[@LINE-2]]
13  // CHECK-Darwin: {{    #0 0x.* in .*NullDeref.*null_deref.cc:}}[[@LINE-3]]
14}
15int main() {
16  NullDeref((int*)0);
17  // CHECK: {{    #1 0x.* in main.*null_deref.cc:}}[[@LINE-1]]
18  // CHECK: {{AddressSanitizer can not provide additional info.}}
19}
20