@@ -1113,6 +1113,12 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
11131113 << P.toDiagnosticString (S.getASTContext ());
11141114 return false ;
11151115 }
1116+ } else if (BothNonNull && P.isIntegralPointer ()) {
1117+ const SourceInfo &Loc = S.Current ->getSource (OpPC);
1118+ S.FFDiag (Loc, diag::note_constexpr_pointer_constant_comparison)
1119+ << LHS.toDiagnosticString (S.getASTContext ())
1120+ << RHS.toDiagnosticString (S.getASTContext ());
1121+ return false ;
11161122 }
11171123 }
11181124
@@ -2389,7 +2395,18 @@ static inline bool PtrPtrCast(InterpState &S, CodePtr OpPC, bool SrcIsVoidPtr) {
23892395 bool HasValidResult = !Ptr.isZero ();
23902396
23912397 if (HasValidResult) {
2392- // FIXME: note_constexpr_invalid_void_star_cast
2398+ if (S.getStdAllocatorCaller (" allocate" ))
2399+ return true ;
2400+
2401+ const auto &E = cast<CastExpr>(S.Current ->getExpr (OpPC));
2402+ if (S.getLangOpts ().CPlusPlus26 &&
2403+ S.getASTContext ().hasSimilarType (Ptr.getType (),
2404+ E->getType ()->getPointeeType ()))
2405+ return true ;
2406+
2407+ S.CCEDiag (E, diag::note_constexpr_invalid_void_star_cast)
2408+ << E->getSubExpr ()->getType () << S.getLangOpts ().CPlusPlus26
2409+ << Ptr.getType ().getCanonicalType () << E->getType ()->getPointeeType ();
23932410 } else if (!S.getLangOpts ().CPlusPlus26 ) {
23942411 const SourceInfo &E = S.Current ->getSource (OpPC);
23952412 S.CCEDiag (E, diag::note_constexpr_invalid_cast)
@@ -2781,10 +2798,9 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
27812798inline bool GetIntPtr (InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
27822799 const T &IntVal = S.Stk .pop <T>();
27832800
2784- if (Desc)
2785- S.CCEDiag (S.Current ->getSource (OpPC), diag::note_constexpr_invalid_cast)
2786- << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
2787- << S.getLangOpts ().CPlusPlus ;
2801+ S.CCEDiag (S.Current ->getSource (OpPC), diag::note_constexpr_invalid_cast)
2802+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
2803+ << S.getLangOpts ().CPlusPlus ;
27882804
27892805 S.Stk .push <Pointer>(static_cast <uint64_t >(IntVal), Desc);
27902806 return true ;
0 commit comments