================ @@ -10742,9 +10742,53 @@ static void DiagnoseBadDivideOrRemainderValues(Sema& S, ExprResult &LHS, << IsDiv << RHS.get()->getSourceRange()); } +static void diagnoseScopedEnums(Sema &S, const SourceLocation Loc, + const ExprResult &LHS, const ExprResult &RHS, + BinaryOperatorKind Opc) { + const Expr *LHSExpr = LHS.get(); + const Expr *RHSExpr = RHS.get(); + if (!LHSExpr || !RHSExpr) + return; + const QualType LHSType = LHSExpr->getType(); + const QualType RHSType = RHSExpr->getType(); + const bool LHSIsScoped = LHSType->isScopedEnumeralType(); + const bool RHSIsScoped = RHSType->isScopedEnumeralType(); + if (!LHSIsScoped && !RHSIsScoped) + return; + if (!LHSIsScoped && !LHSType->isIntegralOrUnscopedEnumerationType()) + return; + if (!RHSIsScoped && !RHSType->isIntegralOrUnscopedEnumerationType()) + return; + if (BinaryOperator::isAssignmentOp(Opc) && LHSIsScoped) + return; + bool isCxx23 = S.getLangOpts().CPlusPlus23; + unsigned diagID = ---------------- erichkeane wrote:
That seems overly verbose to me (and contains things we just don't do in our diagnostics). the static-cast part isn't 'outdated', it is just less specific. I'd be OK with the 2 parts IF we could get the fixit to work 'correctly', but that isn't going to be true if the header for to_underlying isn't included. We COULD possibly split on 'is this declaration available', but an lookup for a note here seems wasteful. https://github.com/llvm/llvm-project/pull/152698 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits