@@ -8103,12 +8103,14 @@ class ExprEvaluatorBase
8103
8103
}
8104
8104
8105
8105
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;
8107
8108
return static_cast<Derived*>(this)->VisitCastExpr(E);
8108
8109
}
8109
8110
bool VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *E) {
8110
8111
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;
8112
8114
return static_cast<Derived*>(this)->VisitCastExpr(E);
8113
8115
}
8114
8116
bool VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E) {
@@ -8833,7 +8835,8 @@ class LValueExprEvaluator
8833
8835
8834
8836
case CK_LValueBitCast:
8835
8837
this->CCEDiag(E, diag::note_constexpr_invalid_cast)
8836
- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
8838
+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
8839
+ << Info.Ctx.getLangOpts().CPlusPlus;
8837
8840
if (!Visit(E->getSubExpr()))
8838
8841
return false;
8839
8842
Result.Designator.setInvalid();
@@ -9670,10 +9673,12 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
9670
9673
<< E->getType()->getPointeeType();
9671
9674
else
9672
9675
CCEDiag(E, diag::note_constexpr_invalid_cast)
9673
- << 3 << SubExpr->getType();
9676
+ << diag::ConstexprInvalidCastKind::CastFrom
9677
+ << SubExpr->getType();
9674
9678
} else
9675
9679
CCEDiag(E, diag::note_constexpr_invalid_cast)
9676
- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
9680
+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
9681
+ << Info.Ctx.getLangOpts().CPlusPlus;
9677
9682
Result.Designator.setInvalid();
9678
9683
}
9679
9684
}
@@ -9712,7 +9717,8 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
9712
9717
9713
9718
case CK_IntegralToPointer: {
9714
9719
CCEDiag(E, diag::note_constexpr_invalid_cast)
9715
- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
9720
+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
9721
+ << Info.Ctx.getLangOpts().CPlusPlus;
9716
9722
9717
9723
APValue Value;
9718
9724
if (!EvaluateIntegerOrLValue(SubExpr, Value, Info))
@@ -11177,7 +11183,8 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) {
11177
11183
// Give up if the input isn't an int, float, or vector. For example, we
11178
11184
// reject "(v4i16)(intptr_t)&a".
11179
11185
Info.FFDiag(E, diag::note_constexpr_invalid_cast)
11180
- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
11186
+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
11187
+ << Info.Ctx.getLangOpts().CPlusPlus;
11181
11188
return false;
11182
11189
}
11183
11190
@@ -15201,7 +15208,8 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
15201
15208
15202
15209
case CK_PointerToIntegral: {
15203
15210
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();
15205
15213
15206
15214
LValue LV;
15207
15215
if (!EvaluatePointer(SubExpr, LV, Info))
0 commit comments