2525#include " InterpStack.h"
2626#include " InterpState.h"
2727#include " MemberPointer.h"
28- #include " Opcode.h"
2928#include " PrimType.h"
3029#include " Program.h"
3130#include " State.h"
@@ -1131,8 +1130,9 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
11311130 S.FFDiag (Loc, diag::note_constexpr_pointer_comparison_past_end)
11321131 << LHS.toDiagnosticString (S.getASTContext ());
11331132 return false ;
1134- } else if (RHS.isOnePastEnd () && !LHS.isOnePastEnd () && !LHS.isZero () &&
1135- LHS.getOffset () == 0 ) {
1133+ }
1134+ if (RHS.isOnePastEnd () && !LHS.isOnePastEnd () && !LHS.isZero () &&
1135+ LHS.getOffset () == 0 ) {
11361136 const SourceInfo &Loc = S.Current ->getSource (OpPC);
11371137 S.FFDiag (Loc, diag::note_constexpr_pointer_comparison_past_end)
11381138 << RHS.toDiagnosticString (S.getASTContext ());
@@ -1150,8 +1150,9 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
11501150 const SourceInfo &Loc = S.Current ->getSource (OpPC);
11511151 S.FFDiag (Loc, diag::note_constexpr_literal_comparison);
11521152 return false ;
1153- } else if (const auto *CE = dyn_cast<CallExpr>(E);
1154- CE && IsOpaqueConstantCall (CE)) {
1153+ }
1154+ if (const auto *CE = dyn_cast<CallExpr>(E);
1155+ CE && IsOpaqueConstantCall (CE)) {
11551156 const SourceInfo &Loc = S.Current ->getSource (OpPC);
11561157 S.FFDiag (Loc, diag::note_constexpr_opaque_call_comparison)
11571158 << P.toDiagnosticString (S.getASTContext ());
@@ -2681,6 +2682,14 @@ static inline bool CastFixedPointIntegral(InterpState &S, CodePtr OpPC) {
26812682 return true ;
26822683}
26832684
2685+ static inline bool FnPtrCast (InterpState &S, CodePtr OpPC) {
2686+ const SourceInfo &E = S.Current ->getSource (OpPC);
2687+ S.CCEDiag (E, diag::note_constexpr_invalid_cast)
2688+ << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
2689+ << S.getLangOpts ().CPlusPlus << S.Current ->getRange (OpPC);
2690+ return true ;
2691+ }
2692+
26842693static inline bool PtrPtrCast (InterpState &S, CodePtr OpPC, bool SrcIsVoidPtr) {
26852694 const auto &Ptr = S.Stk .peek <Pointer>();
26862695
@@ -3266,7 +3275,8 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32663275 S.CCEDiag (Loc, diag::note_constexpr_invalid_cast)
32673276 << static_cast <unsigned >(Kind) << S.Current ->getRange (OpPC);
32683277 return !Fatal;
3269- } else if (Kind == CastKind::Volatile) {
3278+ }
3279+ if (Kind == CastKind::Volatile) {
32703280 if (!S.checkingPotentialConstantExpression ()) {
32713281 const auto *E = cast<CastExpr>(S.Current ->getExpr (OpPC));
32723282 if (S.getLangOpts ().CPlusPlus )
@@ -3277,7 +3287,8 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32773287 }
32783288
32793289 return false ;
3280- } else if (Kind == CastKind::Dynamic) {
3290+ }
3291+ if (Kind == CastKind::Dynamic) {
32813292 assert (!S.getLangOpts ().CPlusPlus20 );
32823293 S.CCEDiag (S.Current ->getSource (OpPC), diag::note_constexpr_invalid_cast)
32833294 << diag::ConstexprInvalidCastKind::Dynamic;
0 commit comments