Skip to content

[Clang] add additional tests for -Wshift-bool #130339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 12, 2025

Conversation

a-tarasyuk
Copy link
Member

@a-tarasyuk a-tarasyuk requested a review from shafik March 7, 2025 20:11
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Mar 7, 2025
@a-tarasyuk a-tarasyuk requested a review from AaronBallman March 7, 2025 20:11
@llvmbot
Copy link
Member

llvmbot commented Mar 7, 2025

@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)

Changes

Fixes #127336 (review)


Full diff: https://github.com/llvm/llvm-project/pull/130339.diff

1 Files Affected:

  • (modified) clang/test/Sema/shift-bool.cpp (+3)
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'}}
 }

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but thought another test might be interesting.

@a-tarasyuk a-tarasyuk requested a review from AaronBallman March 11, 2025 20:47
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@a-tarasyuk a-tarasyuk merged commit c14e459 into llvm:main Mar 12, 2025
11 checks passed
frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants