[clang] [Clang] Add diagnostic when scoped enumeration requires an explicit conversion for binary operations (PR #152698)
Timothy Choi via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 8 22:10:22 PDT 2025
================
@@ -10772,9 +10811,14 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
if (LHS.isInvalid() || RHS.isInvalid())
return QualType();
-
- if (compType.isNull() || !compType->isArithmeticType())
- return InvalidOperands(Loc, LHS, RHS);
+ if (compType.isNull() || !compType->isArithmeticType()) {
+ InvalidOperands(Loc, LHS, RHS);
+ diagnoseScopedEnums(*this, Loc, LHS, RHS,
+ IsCompAssign ? IsDiv ? BO_DivAssign : BO_MulAssign
+ : IsDiv ? BO_Div
+ : BO_Mul);
----------------
tinnamchoi wrote:
Would it be acceptable to change `CheckMultiplyDivideOperands` to take `BinaryOperatorKind Opc` instead of `bool IsCompAssign, bool IsDiv`? It should be even cleaner but I was trying to avoid changing existing function signatures. A lot of these `Check[Operation]Operands` functions have similar inconsistencies where sometimes they take a `BinaryOperatorKind`, `bool`s, or nothing at all. Maybe this can do with a bit of refactoring in the future.
https://github.com/llvm/llvm-project/pull/152698
More information about the cfe-commits
mailing list