@@ -551,8 +551,8 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
551551
552552 if (const auto *VD = Ptr.getDeclDesc ()->asVarDecl ();
553553 VD && (VD->isConstexpr () || VD->hasGlobalStorage ())) {
554- const SourceInfo &Loc = S.Current ->getSource (OpPC);
555554 if (VD->getAnyInitializer ()) {
555+ const SourceInfo &Loc = S.Current ->getSource (OpPC);
556556 S.FFDiag (Loc, diag::note_constexpr_var_init_non_constant, 1 ) << VD;
557557 S.Note (VD->getLocation (), diag::note_declared_at);
558558 } else {
@@ -722,7 +722,6 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
722722 if (F->isLambdaStaticInvoker ())
723723 return true ;
724724
725- const SourceLocation &Loc = S.Current ->getLocation (OpPC);
726725 if (S.getLangOpts ().CPlusPlus11 ) {
727726 const FunctionDecl *DiagDecl = F->getDecl ();
728727
@@ -748,7 +747,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
748747 // or an inheriting constructor, we should be much more explicit about why
749748 // it's not constexpr.
750749 if (CD && CD->isInheritingConstructor ()) {
751- S.FFDiag (Loc, diag::note_constexpr_invalid_inhctor, 1 )
750+ S.FFDiag (S.Current ->getLocation (OpPC),
751+ diag::note_constexpr_invalid_inhctor, 1 )
752752 << CD->getInheritedConstructor ().getConstructor ()->getParent ();
753753 S.Note (DiagDecl->getLocation (), diag::note_declared_at);
754754 } else {
@@ -766,7 +766,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
766766 DiagDecl->hasBody ())
767767 return false ;
768768
769- S.FFDiag (Loc, diag::note_constexpr_invalid_function, 1 )
769+ S.FFDiag (S.Current ->getLocation (OpPC),
770+ diag::note_constexpr_invalid_function, 1 )
770771 << DiagDecl->isConstexpr () << (bool )CD << DiagDecl;
771772
772773 if (DiagDecl->getDefinition ())
@@ -776,7 +777,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
776777 S.Note (DiagDecl->getLocation (), diag::note_declared_at);
777778 }
778779 } else {
779- S.FFDiag (Loc, diag::note_invalid_subexpr_in_const_expr);
780+ S.FFDiag (S.Current ->getLocation (OpPC),
781+ diag::note_invalid_subexpr_in_const_expr);
780782 }
781783
782784 return false ;
@@ -980,11 +982,6 @@ bool CheckNonNullArgs(InterpState &S, CodePtr OpPC, const Function *F,
980982 return true ;
981983}
982984
983- // FIXME: This is similar to code we already have in Compiler.cpp.
984- // I think it makes sense to instead add the field and base destruction stuff
985- // to the destructor Function itself. Then destroying a record would really
986- // _just_ be calling its destructor. That would also help with the diagnostic
987- // difference when the destructor or a field/base fails.
988985static bool runRecordDestructor (InterpState &S, CodePtr OpPC,
989986 const Pointer &BasePtr,
990987 const Descriptor *Desc) {
@@ -1095,8 +1092,8 @@ bool Free(InterpState &S, CodePtr OpPC, bool DeleteIsArrayForm,
10951092
10961093 // For a class type with a virtual destructor, the selected operator delete
10971094 // is the one looked up when building the destructor.
1098- QualType AllocType = Ptr.getType ();
10991095 if (!DeleteIsArrayForm && !IsGlobalDelete) {
1096+ QualType AllocType = Ptr.getType ();
11001097 auto getVirtualOperatorDelete = [](QualType T) -> const FunctionDecl * {
11011098 if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl ())
11021099 if (const CXXDestructorDecl *DD = RD->getDestructor ())
@@ -1344,6 +1341,9 @@ bool Call(InterpState &S, CodePtr OpPC, const Function *Func,
13441341 } else {
13451342 if (!CheckInvoke (S, OpPC, ThisPtr))
13461343 return cleanup ();
1344+ if (!Func->isConstructor () &&
1345+ !CheckActive (S, OpPC, ThisPtr, AK_MemberCall))
1346+ return false ;
13471347 }
13481348
13491349 if (Func->isConstructor () && !checkConstructor (S, OpPC, Func, ThisPtr))
@@ -1515,7 +1515,7 @@ bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t ArgSize,
15151515 // This happens when the call expression has been cast to
15161516 // something else, but we don't support that.
15171517 if (S.Ctx .classify (F->getDecl ()->getReturnType ()) !=
1518- S.Ctx .classify (CE->getType ( )))
1518+ S.Ctx .classify (CE->getCallReturnType (S. getASTContext () )))
15191519 return false ;
15201520
15211521 // Check argument nullability state.
0 commit comments