summaryrefslogtreecommitdiffstats
path: root/test/Sema/shift.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2011-02-26 22:09:03 +0000
committerdim <dim@FreeBSD.org>2011-02-26 22:09:03 +0000
commita0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 (patch)
treeabae0246ec9156cc1a7cbb947b2b0dfe95fa3189 /test/Sema/shift.c
parent39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df (diff)
downloadFreeBSD-src-a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51.zip
FreeBSD-src-a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51.tar.gz
Vendor import of clang trunk r126547:
http://llvm.org/svn/llvm-project/cfe/trunk@126547
Diffstat (limited to 'test/Sema/shift.c')
-rw-r--r--test/Sema/shift.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/Sema/shift.c b/test/Sema/shift.c
index 4273cab..df6b114 100644
--- a/test/Sema/shift.c
+++ b/test/Sema/shift.c
@@ -1,7 +1,9 @@
-// RUN: %clang -Wall -ffreestanding -fsyntax-only -Xclang -verify %s
+// RUN: %clang -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -Xclang -verify %s
#include <limits.h>
+#define WORD_BIT (sizeof(int) * CHAR_BIT)
+
enum {
X = 1 << 0,
Y = 1 << 1,
@@ -32,6 +34,22 @@ void test() {
c <<= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
c >>= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
(void)((long)c << CHAR_BIT);
+
+ int i;
+ i = 1 << (WORD_BIT - 2);
+ i = 2 << (WORD_BIT - 1); // expected-warning {{bits to represent, but 'int' only has}}
+ i = 1 << (WORD_BIT - 1); // expected-warning {{overrides the sign bit of the shift expression}}
+ i = -1 << (WORD_BIT - 1);
+ i = 0 << (WORD_BIT - 1);
+ i = (char)1 << (WORD_BIT - 2);
+
+ unsigned u;
+ u = 1U << (WORD_BIT - 1);
+ u = 5U << (WORD_BIT - 1);
+
+ long long int lli;
+ lli = INT_MIN << 2; // expected-warning {{bits to represent, but 'int' only has}}
+ lli = 1LL << (sizeof(long long) * CHAR_BIT - 2);
}
#define a 0
OpenPOWER on IntegriCloud