================
@@ -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 =
+ isCxx23 ? diag::note_no_implicit_conversion_for_scoped_enum_cxx23
+ : diag::note_no_implicit_conversion_for_scoped_enum;
+ auto diagnosticHelper = [&S, isCxx23, diagID](const Expr *expr, const
QualType type) {
+ SourceLocation beginLoc = expr->getBeginLoc();
+ QualType intType =
+ type->castAs<EnumType>()->getDecl()->getIntegerType();
+ std::string insertionString =
----------------
erichkeane wrote:
You seem to have switched capitalization mid-patch :) Variable name start with
a capital letter:
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
https://github.com/llvm/llvm-project/pull/152698
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits