[clang] [Clang] add -Wshift-bool warning to handle shifting of bool (PR #127336)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 06:50:57 PST 2025
================
@@ -11246,6 +11246,12 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
if (S.getLangOpts().OpenCL)
return;
+ if (LHS.get()->IgnoreParenImpCasts()->getType()->isBooleanType()) {
+ S.Diag(Loc, diag::warn_shift_bool)
+ << (Opc == BO_Shr) /*left|right*/ << LHS.get()->getSourceRange();
----------------
AaronBallman wrote:
I think we should only diagnose right shift (`bool >> val`) for now and not diagnose left shift (`bool << val`).
https://github.com/llvm/llvm-project/pull/127336
More information about the cfe-commits
mailing list