1*673dc3d4SNico Weber // Test the handle_sigill option. 2*673dc3d4SNico Weber // 3*673dc3d4SNico Weber // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0 4*673dc3d4SNico Weber // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 5*673dc3d4SNico Weber // REQUIRES: x86-target-arch 6*673dc3d4SNico Weber 7*673dc3d4SNico Weber #ifdef _WIN32 8*673dc3d4SNico Weber #include <windows.h> 9*673dc3d4SNico Weber #endif 10*673dc3d4SNico Weber main(int argc,char ** argv)11*673dc3d4SNico Weberint main(int argc, char **argv) { 12*673dc3d4SNico Weber #ifdef _WIN32 13*673dc3d4SNico Weber // Sometimes on Windows this test generates a WER fault dialog. Suppress that. 14*673dc3d4SNico Weber UINT new_flags = SEM_FAILCRITICALERRORS | 15*673dc3d4SNico Weber SEM_NOGPFAULTERRORBOX | 16*673dc3d4SNico Weber SEM_NOOPENFILEERRORBOX; 17*673dc3d4SNico Weber // Preserve existing error mode, as discussed at 18*673dc3d4SNico Weber // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx 19*673dc3d4SNico Weber UINT existing_flags = SetErrorMode(new_flags); 20*673dc3d4SNico Weber SetErrorMode(existing_flags | new_flags); 21*673dc3d4SNico Weber #endif 22*673dc3d4SNico Weber 23*673dc3d4SNico Weber if (argc) 24*673dc3d4SNico Weber __builtin_trap(); 25*673dc3d4SNico Weber // Unreachable code to avoid confusing the Windows unwinder. 26*673dc3d4SNico Weber #ifdef _WIN32 27*673dc3d4SNico Weber SetErrorMode(0); 28*673dc3d4SNico Weber #endif 29*673dc3d4SNico Weber } 30*673dc3d4SNico Weber // CHECK0-NOT: ERROR: AddressSanitizer 31*673dc3d4SNico Weber // CHECK1: ERROR: AddressSanitizer: {{ILL|illegal-instruction}} on unknown address {{0x0*}} 32