aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/bitwise-ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/bitwise-ops.c')
-rw-r--r--test/Analysis/bitwise-ops.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/test/Analysis/bitwise-ops.c b/test/Analysis/bitwise-ops.c
index 407aa19289c5..fe546580be3d 100644
--- a/test/Analysis/bitwise-ops.c
+++ b/test/Analysis/bitwise-ops.c
@@ -22,11 +22,32 @@ int testConstantShifts_PR18073(int which) {
case 1:
return 0ULL << 63; // no-warning
case 2:
- return 0ULL << 64; // expected-warning{{The result of the '<<' expression is undefined}}
+ return 0ULL << 64; // expected-warning{{The result of the left shift is undefined due to shifting by '64', which is greater or equal to the width of type 'unsigned long long'}}
case 3:
- return 0ULL << 65; // expected-warning{{The result of the '<<' expression is undefined}}
+ return 0ULL << 65; // expected-warning{{The result of the left shift is undefined due to shifting by '65', which is greater or equal to the width of type 'unsigned long long'}}
default:
return 0;
}
-} \ No newline at end of file
+}
+
+int testOverflowShift(int a) {
+ if (a == 323) {
+ return 1 << a; // expected-warning{{The result of the left shift is undefined due to shifting by '323', which is greater or equal to the width of type 'int'}}
+ }
+ return 0;
+}
+
+int testNegativeShift(int a) {
+ if (a == -5) {
+ return 1 << a; // expected-warning{{The result of the left shift is undefined because the right operand is negative}}
+ }
+ return 0;
+}
+
+int testNegativeLeftShift(int a) {
+ if (a == -3) {
+ return a << 1; // expected-warning{{The result of the left shift is undefined because the left operand is negative}}
+ }
+ return 0;
+}