@@ -1915,6 +1915,9 @@ bool Load(InterpState &S, CodePtr OpPC) {
19151915 return false ;
19161916 if (!Ptr.isBlockPointer ())
19171917 return false ;
1918+ if (const Descriptor *D = Ptr.getFieldDesc ();
1919+ !(D->isPrimitive () || D->isPrimitiveArray ()) || D->getPrimType () != Name)
1920+ return false ;
19181921 S.Stk .push <T>(Ptr.deref <T>());
19191922 return true ;
19201923}
@@ -1926,6 +1929,9 @@ bool LoadPop(InterpState &S, CodePtr OpPC) {
19261929 return false ;
19271930 if (!Ptr.isBlockPointer ())
19281931 return false ;
1932+ if (const Descriptor *D = Ptr.getFieldDesc ();
1933+ !(D->isPrimitive () || D->isPrimitiveArray ()) || D->getPrimType () != Name)
1934+ return false ;
19291935 S.Stk .push <T>(Ptr.deref <T>());
19301936 return true ;
19311937}
@@ -3288,12 +3294,18 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32883294 bool Fatal) {
32893295 const SourceLocation &Loc = S.Current ->getLocation (OpPC);
32903296
3291- if (Kind == CastKind::Reinterpret) {
3297+ switch (Kind) {
3298+ case CastKind::Reinterpret:
32923299 S.CCEDiag (Loc, diag::note_constexpr_invalid_cast)
3293- << static_cast <unsigned >(Kind) << S.Current ->getRange (OpPC);
3300+ << diag::ConstexprInvalidCastKind::Reinterpret
3301+ << S.Current ->getRange (OpPC);
32943302 return !Fatal;
3295- }
3296- 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:
32973309 if (!S.checkingPotentialConstantExpression ()) {
32983310 const auto *E = cast<CastExpr>(S.Current ->getExpr (OpPC));
32993311 if (S.getLangOpts ().CPlusPlus )
@@ -3304,14 +3316,13 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
33043316 }
33053317
33063318 return false ;
3307- }
3308- if (Kind == CastKind::Dynamic) {
3319+ case CastKind::Dynamic:
33093320 assert (!S.getLangOpts ().CPlusPlus20 );
3310- S.CCEDiag (S. Current -> getSource (OpPC) , diag::note_constexpr_invalid_cast)
3321+ S.CCEDiag (Loc , diag::note_constexpr_invalid_cast)
33113322 << diag::ConstexprInvalidCastKind::Dynamic;
33123323 return true ;
33133324 }
3314-
3325+ llvm_unreachable ( " Unhandled CastKind " );
33153326 return false ;
33163327}
33173328
0 commit comments