[clang] [Clang] add -Wshift-bool warning to handle shifting of bool (PR #127336)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 12:20:41 PST 2025


================
@@ -11247,6 +11247,12 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
   if (S.getLangOpts().OpenCL)
     return;
 
+  if (Opc == BO_Shr &&
+      LHS.get()->IgnoreParenImpCasts()->getType()->isBooleanType()) {
+    S.Diag(Loc, diag::warn_shift_bool) << LHS.get()->getSourceRange();
+    return;
----------------
a-tarasyuk wrote:

@AaronBallman, thanks for the feedback. I've removed the return to proceed with other diagnostics 

https://github.com/llvm/llvm-project/pull/127336


More information about the cfe-commits mailing list