brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · c7bdf7c Raw
31 lines · cpp
1// RUN: %clang -x c -fsanitize=pointer-overflow %s -o %t2// RUN: %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NOTYPE3// RUN: %env_ubsan_opts=report_error_type=1 %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE4 5// RUN: %clangxx -fsanitize=pointer-overflow %s -o %t6// RUN: %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NOTYPE7// RUN: %env_ubsan_opts=report_error_type=1 %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE8 9#include <stdlib.h>10 11int main(int argc, char *argv[]) {12  char *base, *result;13 14  base = (char *)0;15  result = base + 0;16  // CHECK-NOTYPE-NOT: SUMMARY:17  // CHECK-TYPE-NOT: SUMMARY:18 19  base = (char *)0;20  result = base + 1;21  // CHECK-NOTYPE: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:1722  // CHECK-TYPE: SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset {{.*}}summary.cpp:[[@LINE-2]]:1723 24  base = (char *)1;25  result = base - 1;26  // CHECK-NOTYPE: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:1727  // CHECK-TYPE: SUMMARY: UndefinedBehaviorSanitizer: nullptr-after-nonzero-offset {{.*}}summary.cpp:[[@LINE-2]]:1728 29  return 0;30}31