brintos

brintos / llvm-project-archived public Read only

0
0
Text · 836 B · 0b54579 Raw
40 lines · cpp
1// RUN: %clangxx_min_runtime -w -fsanitize=signed-integer-overflow,nullability-return,returns-nonnull-attribute -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s2 3#include <stdint.h>4#include <stdio.h>5 6int *_Nonnull h() {7  // CHECK: nullability-return by 0x{{[[:xdigit:]]+$}}8  return NULL;9}10 11__attribute__((returns_nonnull))12int *i() {13  // CHECK: nonnull-return by 0x{{[[:xdigit:]]+$}}14  return NULL;15}16 17__attribute__((noinline))18int f(int x, int y) {19  // CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}}20  return x * y;21}22 23__attribute__((noinline))24int g(int x, int y) {25  // CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}}26  return x * (y + 1);27}28 29int main() {30  h();31  i();32  int x = 2;33  for (int i = 0; i < 10; ++i)34    x = f(x, x);35  x = 2;36  for (int i = 0; i < 10; ++i)37    x = g(x, x);38  // CHECK-NOT: mul-overflow39}40