@@ -857,23 +857,22 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
857857 return false ;
858858 }
859859
860- // Bail out if the function declaration itself is invalid. We will
861- // have produced a relevant diagnostic while parsing it, so just
862- // note the problematic sub-expression.
863- if (F->getDecl ()->isInvalidDecl ())
864- return Invalid (S, OpPC);
865-
866860 if (S.checkingPotentialConstantExpression () && S.Current ->getDepth () != 0 )
867861 return false ;
868862
869- if (F->isConstexpr () && F->hasBody () &&
870- (F->getDecl ()->isConstexpr () || F->getDecl ()->hasAttr <MSConstexprAttr>()))
863+ if (F->isValid () && F->hasBody () && F->isConstexpr ())
871864 return true ;
872865
873866 // Implicitly constexpr.
874867 if (F->isLambdaStaticInvoker ())
875868 return true ;
876869
870+ // Bail out if the function declaration itself is invalid. We will
871+ // have produced a relevant diagnostic while parsing it, so just
872+ // note the problematic sub-expression.
873+ if (F->getDecl ()->isInvalidDecl ())
874+ return Invalid (S, OpPC);
875+
877876 // Diagnose failed assertions specially.
878877 if (S.Current ->getLocation (OpPC).isMacroID () &&
879878 F->getDecl ()->getIdentifier ()) {
@@ -923,7 +922,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
923922 // for a constant expression. It might be defined at the point we're
924923 // actually calling it.
925924 bool IsExtern = DiagDecl->getStorageClass () == SC_Extern;
926- if (!DiagDecl->isDefined () && !IsExtern && DiagDecl->isConstexpr () &&
925+ bool IsDefined = F->isDefined ();
926+ if (!IsDefined && !IsExtern && DiagDecl->isConstexpr () &&
927927 S.checkingPotentialConstantExpression ())
928928 return false ;
929929
0 commit comments