@@ -1914,6 +1914,10 @@ bool Load(InterpState &S, CodePtr OpPC) {
19141914 return false ;
19151915 if (!Ptr.isBlockPointer ())
19161916 return false ;
1917+ if (!(Ptr.getFieldDesc ()->isPrimitive () ||
1918+ Ptr.getFieldDesc ()->isPrimitiveArray ()) ||
1919+ Ptr.getFieldDesc ()->getPrimType () != Name)
1920+ return false ;
19171921 S.Stk .push <T>(Ptr.deref <T>());
19181922 return true ;
19191923}
@@ -1925,6 +1929,10 @@ bool LoadPop(InterpState &S, CodePtr OpPC) {
19251929 return false ;
19261930 if (!Ptr.isBlockPointer ())
19271931 return false ;
1932+ if (!(Ptr.getFieldDesc ()->isPrimitive () ||
1933+ Ptr.getFieldDesc ()->isPrimitiveArray ()) ||
1934+ Ptr.getFieldDesc ()->getPrimType () != Name)
1935+ return false ;
19281936 S.Stk .push <T>(Ptr.deref <T>());
19291937 return true ;
19301938}
@@ -3286,12 +3294,18 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32863294 bool Fatal) {
32873295 const SourceLocation &Loc = S.Current ->getLocation (OpPC);
32883296
3289- if (Kind == CastKind::Reinterpret) {
3297+ switch (Kind) {
3298+ case CastKind::Reinterpret:
32903299 S.CCEDiag (Loc, diag::note_constexpr_invalid_cast)
3291- << static_cast <unsigned >(Kind) << S.Current ->getRange (OpPC);
3300+ << diag::ConstexprInvalidCastKind::Reinterpret
3301+ << S.Current ->getRange (OpPC);
32923302 return !Fatal;
3293- }
3294- if (Kind == CastKind::Volatile) {
3303+ case CastKind::ReinterpretLike:
3304+ S.CCEDiag (Loc, diag::note_constexpr_invalid_cast)
3305+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
3306+ << S.getLangOpts ().CPlusPlus << S.Current ->getRange (OpPC);
3307+ return !Fatal;
3308+ case CastKind::Volatile:
32953309 if (!S.checkingPotentialConstantExpression ()) {
32963310 const auto *E = cast<CastExpr>(S.Current ->getExpr (OpPC));
32973311 if (S.getLangOpts ().CPlusPlus )
@@ -3302,14 +3316,13 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
33023316 }
33033317
33043318 return false ;
3305- }
3306- if (Kind == CastKind::Dynamic) {
3319+ case CastKind::Dynamic:
33073320 assert (!S.getLangOpts ().CPlusPlus20 );
3308- S.CCEDiag (S. Current -> getSource (OpPC) , diag::note_constexpr_invalid_cast)
3321+ S.CCEDiag (Loc , diag::note_constexpr_invalid_cast)
33093322 << diag::ConstexprInvalidCastKind::Dynamic;
33103323 return true ;
33113324 }
3312-
3325+ llvm_unreachable ( " Unhandled CastKind " );
33133326 return false ;
33143327}
33153328
0 commit comments