From cb2d6caa93d19e64ec782d5ea04d6b1611cb2c10 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 24 Aug 2016 17:36:20 +0000 Subject: Vendor import of clang release_39 branch r279477: https://llvm.org/svn/llvm-project/cfe/branches/release_39@279477 --- test/CodeGen/wrapv-lshr-sanitize.c | 12 ++++++++++++ test/Sema/negative-shift-wrapv.c | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/CodeGen/wrapv-lshr-sanitize.c create mode 100644 test/Sema/negative-shift-wrapv.c (limited to 'test') diff --git a/test/CodeGen/wrapv-lshr-sanitize.c b/test/CodeGen/wrapv-lshr-sanitize.c new file mode 100644 index 000000000000..c09dab7cf7b5 --- /dev/null +++ b/test/CodeGen/wrapv-lshr-sanitize.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple x86_64-linux-gnu -fwrapv | FileCheck %s + +// CHECK-LABEL: @lsh_overflow +int lsh_overflow(int a, int b) { + // CHECK-NOT: br + // CHECK-NOT: call void @__ubsan_ + // CHECK-NOT: call void @llvm.trap + + // CHECK: %[[RET:.*]] = shl i32 + // CHECK-NEXT: ret i32 %[[RET]] + return a << b; +} diff --git a/test/Sema/negative-shift-wrapv.c b/test/Sema/negative-shift-wrapv.c new file mode 100644 index 000000000000..b8748201ffc0 --- /dev/null +++ b/test/Sema/negative-shift-wrapv.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s + +int test() { + int i; + i = -1 << 1; // no-warning + return i; +} + +// expected-no-diagnostics -- cgit v1.3