Skip to content

Commit 9be7657

Browse files
committed
add c test
1 parent bed2cb0 commit 9be7657

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

clang/test/Sema/shift-bool.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 -fsyntax-only -Wshift-bool -verify %s
2+
3+
void t() {
4+
int x = 10;
5+
int y = 1;
6+
7+
int a = y << x;
8+
int b = y >> x;
9+
10+
int c = 0 << x;
11+
int d = 0 >> x;
12+
13+
int e = y << 1;
14+
int f = y >> 1;
15+
16+
int g = y << -1; // expected-warning {{shift count is negative}}
17+
int h = y >> -1; // expected-warning {{shift count is negative}}
18+
19+
int i = y << 0;
20+
int j = y >> 0;
21+
22+
if ((y << 1) != 0) { }
23+
if ((y >> 1) != 0) { }
24+
}

clang/test/Sema/shift-bool.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
void t() {
44
int x = 10;
55
bool y = true;
6-
int z = 1;
76

87
bool a = y << x;
98
bool b = y >> x; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
@@ -23,6 +22,4 @@ void t() {
2322

2423
if ((y << 1) != 0) { }
2524
if ((y >> 1) != 0) { } // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
26-
27-
bool k = (x < z) >> 1; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
2825
}

0 commit comments

Comments
 (0)