@@ -579,57 +579,61 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
579
579
return false ;
580
580
}
581
581
582
- if (!F->isConstexpr () || !F->hasBody ()) {
583
- const SourceLocation &Loc = S.Current ->getLocation (OpPC);
584
- if (S.getLangOpts ().CPlusPlus11 ) {
585
- const FunctionDecl *DiagDecl = F->getDecl ();
582
+ if (F->isConstexpr () && F->hasBody () && F->getDecl ()->isConstexpr ())
583
+ return true ;
586
584
587
- // Invalid decls have been diagnosed before .
588
- if (DiagDecl-> isInvalidDecl ())
589
- return false ;
585
+ // Implicitly constexpr .
586
+ if (F-> isLambdaStaticInvoker ())
587
+ return true ;
590
588
591
- // If this function is not constexpr because it is an inherited
592
- // non-constexpr constructor, diagnose that directly.
593
- const auto *CD = dyn_cast<CXXConstructorDecl>(DiagDecl);
594
- if (CD && CD->isInheritingConstructor ()) {
595
- const auto *Inherited = CD->getInheritedConstructor ().getConstructor ();
596
- if (!Inherited->isConstexpr ())
597
- DiagDecl = CD = Inherited;
598
- }
589
+ const SourceLocation &Loc = S.Current ->getLocation (OpPC);
590
+ if (S.getLangOpts ().CPlusPlus11 ) {
591
+ const FunctionDecl *DiagDecl = F->getDecl ();
592
+
593
+ // Invalid decls have been diagnosed before.
594
+ if (DiagDecl->isInvalidDecl ())
595
+ return false ;
596
+
597
+ // If this function is not constexpr because it is an inherited
598
+ // non-constexpr constructor, diagnose that directly.
599
+ const auto *CD = dyn_cast<CXXConstructorDecl>(DiagDecl);
600
+ if (CD && CD->isInheritingConstructor ()) {
601
+ const auto *Inherited = CD->getInheritedConstructor ().getConstructor ();
602
+ if (!Inherited->isConstexpr ())
603
+ DiagDecl = CD = Inherited;
604
+ }
599
605
600
- // FIXME: If DiagDecl is an implicitly-declared special member function
601
- // or an inheriting constructor, we should be much more explicit about why
602
- // it's not constexpr.
603
- if (CD && CD->isInheritingConstructor ()) {
604
- S.FFDiag (Loc, diag::note_constexpr_invalid_inhctor, 1 )
606
+ // FIXME: If DiagDecl is an implicitly-declared special member function
607
+ // or an inheriting constructor, we should be much more explicit about why
608
+ // it's not constexpr.
609
+ if (CD && CD->isInheritingConstructor ()) {
610
+ S.FFDiag (Loc, diag::note_constexpr_invalid_inhctor, 1 )
605
611
<< CD->getInheritedConstructor ().getConstructor ()->getParent ();
606
- S.Note (DiagDecl->getLocation (), diag::note_declared_at);
607
- } else {
608
- // Don't emit anything if the function isn't defined and we're checking
609
- // for a constant expression. It might be defined at the point we're
610
- // actually calling it.
611
- bool IsExtern = DiagDecl->getStorageClass () == SC_Extern;
612
- if (!DiagDecl->isDefined () && !IsExtern &&
613
- S.checkingPotentialConstantExpression ())
614
- return false ;
612
+ S.Note (DiagDecl->getLocation (), diag::note_declared_at);
613
+ } else {
614
+ // Don't emit anything if the function isn't defined and we're checking
615
+ // for a constant expression. It might be defined at the point we're
616
+ // actually calling it.
617
+ bool IsExtern = DiagDecl->getStorageClass () == SC_Extern;
618
+ if (!DiagDecl->isDefined () && !IsExtern && DiagDecl-> isConstexpr () &&
619
+ S.checkingPotentialConstantExpression ())
620
+ return false ;
615
621
616
- // If the declaration is defined, declared 'constexpr' _and_ has a body,
617
- // the below diagnostic doesn't add anything useful.
618
- if (DiagDecl->isDefined () && DiagDecl->isConstexpr () &&
619
- DiagDecl->hasBody ())
620
- return false ;
622
+ // If the declaration is defined, declared 'constexpr' _and_ has a body,
623
+ // the below diagnostic doesn't add anything useful.
624
+ if (DiagDecl->isDefined () && DiagDecl->isConstexpr () &&
625
+ DiagDecl->hasBody ())
626
+ return false ;
621
627
622
- S.FFDiag (Loc, diag::note_constexpr_invalid_function, 1 )
628
+ S.FFDiag (Loc, diag::note_constexpr_invalid_function, 1 )
623
629
<< DiagDecl->isConstexpr () << (bool )CD << DiagDecl;
624
- S.Note (DiagDecl->getLocation (), diag::note_declared_at);
625
- }
626
- } else {
627
- S.FFDiag (Loc, diag::note_invalid_subexpr_in_const_expr);
630
+ S.Note (DiagDecl->getLocation (), diag::note_declared_at);
628
631
}
629
- return false ;
632
+ } else {
633
+ S.FFDiag (Loc, diag::note_invalid_subexpr_in_const_expr);
630
634
}
631
635
632
- return true ;
636
+ return false ;
633
637
}
634
638
635
639
bool CheckCallDepth (InterpState &S, CodePtr OpPC) {
0 commit comments