1 // REQUIRES: arch=x86_64 2 // 3 // RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t 4 // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER 5 // RUN: %clangxx -fsanitize=builtin -fno-sanitize-recover=builtin -w %s -O3 -o %t.abort 6 // RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT 7 8 void check_ctz(int n) { 9 // ABORT: builtins.cpp:[[@LINE+2]]:17: runtime error: passing zero to ctz(), which is not a valid argument 10 // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to ctz(), which is not a valid argument 11 __builtin_ctz(n); 12 13 // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to ctz(), which is not a valid argument 14 __builtin_ctzl(n); 15 16 // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to ctz(), which is not a valid argument 17 __builtin_ctzll(n); 18 } 19 20 void check_clz(int n) { 21 // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to clz(), which is not a valid argument 22 __builtin_clz(n); 23 24 // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to clz(), which is not a valid argument 25 __builtin_clzl(n); 26 27 // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to clz(), which is not a valid argument 28 __builtin_clzll(n); 29 } 30 31 int main() { 32 check_ctz(0); 33 check_clz(0); 34 return 0; 35 } 36