[clang] [Clang] add additional tests for -Wshift-bool (PR #130339)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 7 12:11:35 PST 2025
https://github.com/a-tarasyuk created https://github.com/llvm/llvm-project/pull/130339
Fixes https://github.com/llvm/llvm-project/pull/127336#pullrequestreview-2665950553
>From bed2cb009ae2e560aa00f86b90c57d82f97bb435 Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Fri, 7 Mar 2025 22:10:24 +0200
Subject: [PATCH] [Clang] add additional tests for -Wshift-bool
---
clang/test/Sema/shift-bool.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/test/Sema/shift-bool.cpp b/clang/test/Sema/shift-bool.cpp
index a17a0e0ad9e7d..efaca65aacaed 100644
--- a/clang/test/Sema/shift-bool.cpp
+++ b/clang/test/Sema/shift-bool.cpp
@@ -3,6 +3,7 @@
void t() {
int x = 10;
bool y = true;
+ int z = 1;
bool a = y << x;
bool b = y >> x; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
@@ -22,4 +23,6 @@ void t() {
if ((y << 1) != 0) { }
if ((y >> 1) != 0) { } // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
+
+ bool k = (x < z) >> 1; // expected-warning {{right shifting a 'bool' implicitly converts it to 'int'}}
}
More information about the cfe-commits
mailing list