1*673dc3d4SNico Weber // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
2*673dc3d4SNico Weber // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
3*673dc3d4SNico Weber // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
4*673dc3d4SNico Weber // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
5*673dc3d4SNico Weber 
6*673dc3d4SNico Weber __attribute__((noinline))
7*673dc3d4SNico Weber // FIXME: Static symbols don't show up in PDBs. We can remove this once we start
8*673dc3d4SNico Weber // using DWARF.
9*673dc3d4SNico Weber #ifndef _MSC_VER
10*673dc3d4SNico Weber static
11*673dc3d4SNico Weber #endif
NullDeref(int * ptr)12*673dc3d4SNico Weber void NullDeref(int *ptr) {
13*673dc3d4SNico Weber   // CHECK: ERROR: AddressSanitizer: {{SEGV|access-violation}} on unknown address
14*673dc3d4SNico Weber   // CHECK:   {{0x0*000.. .*pc 0x.*}}
15*673dc3d4SNico Weber   ptr[10]++;  // BOOM
16*673dc3d4SNico Weber   // atos on Mac cannot extract the symbol name correctly. Also, on FreeBSD 9.2
17*673dc3d4SNico Weber   // the demangling function rejects local names with 'L' in front of them.
18*673dc3d4SNico Weber   // CHECK: {{    #0 0x.* in .*NullDeref.*null_deref.cpp}}
19*673dc3d4SNico Weber }
main()20*673dc3d4SNico Weber int main() {
21*673dc3d4SNico Weber   NullDeref((int*)0);
22*673dc3d4SNico Weber   // CHECK: {{    #1 0x.* in main.*null_deref.cpp}}
23*673dc3d4SNico Weber   // CHECK: AddressSanitizer can not provide additional info.
24*673dc3d4SNico Weber }
25