[LVI] Add trunc to i1 handling. (#124480)
[llvm-project.git] / compiler-rt / test / ubsan / TestCases / Pointer / nullptr-and-nonzero-offset-summary.cpp
blobc7bdf7cd8a5a270fbf735daa1043f32ec8356ae7
1 // RUN: %clang -x c -fsanitize=pointer-overflow %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NOTYPE
3 // RUN: %env_ubsan_opts=report_error_type=1 %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE
5 // RUN: %clangxx -fsanitize=pointer-overflow %s -o %t
6 // RUN: %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NOTYPE
7 // RUN: %env_ubsan_opts=report_error_type=1 %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE
9 #include <stdlib.h>
11 int main(int argc, char *argv[]) {
12 char *base, *result;
14 base = (char *)0;
15 result = base + 0;
16 // CHECK-NOTYPE-NOT: SUMMARY:
17 // CHECK-TYPE-NOT: SUMMARY:
19 base = (char *)0;
20 result = base + 1;
21 // CHECK-NOTYPE: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:17
22 // CHECK-TYPE: SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset {{.*}}summary.cpp:[[@LINE-2]]:17
24 base = (char *)1;
25 result = base - 1;
26 // CHECK-NOTYPE: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:17
27 // CHECK-TYPE: SUMMARY: UndefinedBehaviorSanitizer: nullptr-after-nonzero-offset {{.*}}summary.cpp:[[@LINE-2]]:17
29 return 0;