26 lines · c
1// RUN: %clang_min_runtime -fsanitize=implicit-signed-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK2 3#include <stdint.h>4 5int main() {6// CHECK-NOT: implicit-conversion7 8 // Negative tests. Even if they produce unexpected results, this sanitizer does not care.9 int8_t n0 = (~((uint32_t)(0))); // ~0 -> -1, but do not warn.10 uint8_t n2 = 128;11 uint8_t n3 = 255;12 // Bools do not count13 _Bool b0 = (~((uint32_t)(0)));14 _Bool b1 = 255;15 16 // Explicit and-ing of bits will silence it.17 uint8_t nc0 = ((int32_t)(-1)) & 255;18 19 // Positive tests.20 uint8_t t0 = (int32_t)(-1);21// CHECK: implicit-conversion by 0x{{[[:xdigit:]]+$}}22// CHECK-NOT: implicit-conversion23 24 return 0;25}26