@@ -1914,6 +1914,9 @@ bool Load(InterpState &S, CodePtr OpPC) {
19141914 return false ;
19151915 if (!Ptr.isBlockPointer ())
19161916 return false ;
1917+ if (!Ptr.getFieldDesc ()->isPrimitive () ||
1918+ Ptr.getFieldDesc ()->getPrimType () != Name)
1919+ return false ;
19171920 S.Stk .push <T>(Ptr.deref <T>());
19181921 return true ;
19191922}
@@ -1925,6 +1928,9 @@ bool LoadPop(InterpState &S, CodePtr OpPC) {
19251928 return false ;
19261929 if (!Ptr.isBlockPointer ())
19271930 return false ;
1931+ if (!Ptr.getFieldDesc ()->isPrimitive () ||
1932+ Ptr.getFieldDesc ()->getPrimType () != Name)
1933+ return false ;
19281934 S.Stk .push <T>(Ptr.deref <T>());
19291935 return true ;
19301936}
@@ -3286,12 +3292,18 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32863292 bool Fatal) {
32873293 const SourceLocation &Loc = S.Current ->getLocation (OpPC);
32883294
3289- if (Kind == CastKind::Reinterpret) {
3295+ switch (Kind) {
3296+ case CastKind::Reinterpret:
32903297 S.CCEDiag (Loc, diag::note_constexpr_invalid_cast)
3291- << static_cast <unsigned >(Kind) << S.Current ->getRange (OpPC);
3298+ << diag::ConstexprInvalidCastKind::Reinterpret
3299+ << S.Current ->getRange (OpPC);
32923300 return !Fatal;
3293- }
3294- if (Kind == CastKind::Volatile) {
3301+ case CastKind::ReinterpretLike:
3302+ S.CCEDiag (Loc, diag::note_constexpr_invalid_cast)
3303+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
3304+ << S.getLangOpts ().CPlusPlus << S.Current ->getRange (OpPC);
3305+ return !Fatal;
3306+ case CastKind::Volatile:
32953307 if (!S.checkingPotentialConstantExpression ()) {
32963308 const auto *E = cast<CastExpr>(S.Current ->getExpr (OpPC));
32973309 if (S.getLangOpts ().CPlusPlus )
@@ -3302,14 +3314,13 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
33023314 }
33033315
33043316 return false ;
3305- }
3306- if (Kind == CastKind::Dynamic) {
3317+ case CastKind::Dynamic:
33073318 assert (!S.getLangOpts ().CPlusPlus20 );
3308- S.CCEDiag (S. Current -> getSource (OpPC) , diag::note_constexpr_invalid_cast)
3319+ S.CCEDiag (Loc , diag::note_constexpr_invalid_cast)
33093320 << diag::ConstexprInvalidCastKind::Dynamic;
33103321 return true ;
33113322 }
3312-
3323+ llvm_unreachable ( " Unhandled CastKind " );
33133324 return false ;
33143325}
33153326
0 commit comments