[clang] [Clang] add -Wshift-bool warning to handle shifting of bool (PR #127336)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 21 04:51:29 PST 2025
================
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -Wshift-bool -verify %s
+
+void t() {
+ int x = 10;
+ bool y = true;
+
+ bool a = y >> x; // expected-warning {{right shifting a `bool` implicitly converts it to 'int'}}
+ bool b = false >> x; // expected-warning {{right shifting a `bool` implicitly converts it to 'int'}}
+ bool c = y >> 5; // expected-warning {{right shifting a `bool` implicitly converts it to 'int'}}
+ bool d = y >> -1; // expected-warning {{right shifting a `bool` implicitly converts it to 'int'}}
+ bool e = y >> 0; // expected-warning {{right shifting a `bool` implicitly converts it to 'int'}}
----------------
a-tarasyuk wrote:
@Fznamznon Thanks for the review. I've updated the test cases.
https://github.com/llvm/llvm-project/pull/127336
More information about the cfe-commits
mailing list