brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 5350da9 Raw
29 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -Wshift-bool -verify %s2 3void t() {4  int x = 10;5  bool y = true;6  int z = 1;7 8  bool a = y << x;9  bool b = y >> x; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}10 11  bool c = false << x;12  bool d = false >> x; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}13 14  bool e = y << 1;15  bool f = y >> 1; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}16 17  bool g = y << -1; // expected-warning {{shift count is negative}}18  bool h = y >> -1; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}} \19                    // expected-warning {{shift count is negative}}20 21  bool i = y << 0;22  bool j = y >> 0; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}23 24  bool k = (x < z) >> 1; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}25 26  if ((y << 1) != 0) { }27  if ((y >> 1) != 0) { } // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}28}29