@@ -8103,12 +8103,14 @@ class ExprEvaluatorBase
81038103 }
81048104
81058105 bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) {
8106- CCEDiag(E, diag::note_constexpr_invalid_cast) << 0;
8106+ CCEDiag(E, diag::note_constexpr_invalid_cast)
8107+ << diag::ConstexprInvalidCastKind::Reinterpret;
81078108 return static_cast<Derived*>(this)->VisitCastExpr(E);
81088109 }
81098110 bool VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *E) {
81108111 if (!Info.Ctx.getLangOpts().CPlusPlus20)
8111- CCEDiag(E, diag::note_constexpr_invalid_cast) << 1;
8112+ CCEDiag(E, diag::note_constexpr_invalid_cast)
8113+ << diag::ConstexprInvalidCastKind::Dynamic;
81128114 return static_cast<Derived*>(this)->VisitCastExpr(E);
81138115 }
81148116 bool VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E) {
@@ -8833,7 +8835,8 @@ class LValueExprEvaluator
88338835
88348836 case CK_LValueBitCast:
88358837 this->CCEDiag(E, diag::note_constexpr_invalid_cast)
8836- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
8838+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
8839+ << Info.Ctx.getLangOpts().CPlusPlus;
88378840 if (!Visit(E->getSubExpr()))
88388841 return false;
88398842 Result.Designator.setInvalid();
@@ -9670,10 +9673,12 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
96709673 << E->getType()->getPointeeType();
96719674 else
96729675 CCEDiag(E, diag::note_constexpr_invalid_cast)
9673- << 3 << SubExpr->getType();
9676+ << diag::ConstexprInvalidCastKind::CastFrom
9677+ << SubExpr->getType();
96749678 } else
96759679 CCEDiag(E, diag::note_constexpr_invalid_cast)
9676- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
9680+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
9681+ << Info.Ctx.getLangOpts().CPlusPlus;
96779682 Result.Designator.setInvalid();
96789683 }
96799684 }
@@ -9712,7 +9717,8 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
97129717
97139718 case CK_IntegralToPointer: {
97149719 CCEDiag(E, diag::note_constexpr_invalid_cast)
9715- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
9720+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
9721+ << Info.Ctx.getLangOpts().CPlusPlus;
97169722
97179723 APValue Value;
97189724 if (!EvaluateIntegerOrLValue(SubExpr, Value, Info))
@@ -11177,7 +11183,8 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) {
1117711183 // Give up if the input isn't an int, float, or vector. For example, we
1117811184 // reject "(v4i16)(intptr_t)&a".
1117911185 Info.FFDiag(E, diag::note_constexpr_invalid_cast)
11180- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
11186+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
11187+ << Info.Ctx.getLangOpts().CPlusPlus;
1118111188 return false;
1118211189 }
1118311190
@@ -15201,7 +15208,8 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
1520115208
1520215209 case CK_PointerToIntegral: {
1520315210 CCEDiag(E, diag::note_constexpr_invalid_cast)
15204- << 2 << Info.Ctx.getLangOpts().CPlusPlus << E->getSourceRange();
15211+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
15212+ << Info.Ctx.getLangOpts().CPlusPlus << E->getSourceRange();
1520515213
1520615214 LValue LV;
1520715215 if (!EvaluatePointer(SubExpr, LV, Info))
0 commit comments