File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -fsyntax-only -Wshift-bool -verify %s
2+
3+ void t () {
4+ int x = 10 ;
5+ int y = 5 ;
6+
7+ int a = (x < y ) << 1 ;
8+ int b = (x < y ) >> 1 ;
9+
10+ int c = (x > y ) << 1 ;
11+ int d = (x > y ) >> 1 ;
12+
13+ int e = (x == y ) << 1 ;
14+ int f = (x == y ) >> 1 ;
15+
16+ int g = (x != y ) << 1 ;
17+ int h = (x != y ) >> 1 ;
18+
19+ int i = (x < y ) << 0 ;
20+ int j = (x < y ) >> 0 ;
21+
22+ int k = (x < y ) << -1 ; // expected-warning {{shift count is negative}}
23+ int l = (x < y ) >> -1 ; // expected-warning {{shift count is negative}}
24+
25+ if (((x < y ) << 1 ) != 0 ) { }
26+ if (((x < y ) >> 1 ) != 0 ) { }
27+ }
Original file line number Diff line number Diff line change 33void t () {
44 int x = 10 ;
55 bool y = true ;
6+ int z = 1 ;
67
78 bool a = y << x;
89 bool b = y >> x; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
@@ -20,6 +21,8 @@ void t() {
2021 bool i = y << 0 ;
2122 bool j = y >> 0 ; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
2223
24+ bool k = (x < z) >> 1 ; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
25+
2326 if ((y << 1 ) != 0 ) { }
2427 if ((y >> 1 ) != 0 ) { } // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
2528}
You can’t perform that action at this time.
0 commit comments