@@ -350,11 +350,6 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
350
350
}
351
351
352
352
if (!F->isConstexpr ()) {
353
- // Don't emit anything if we're checking for a potential constant
354
- // expression. That will happen later when actually executing.
355
- if (S.checkingPotentialConstantExpression ())
356
- return false ;
357
-
358
353
const SourceLocation &Loc = S.Current ->getLocation (OpPC);
359
354
if (S.getLangOpts ().CPlusPlus11 ) {
360
355
const FunctionDecl *DiagDecl = F->getDecl ();
@@ -371,13 +366,21 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
371
366
// FIXME: If DiagDecl is an implicitly-declared special member function
372
367
// or an inheriting constructor, we should be much more explicit about why
373
368
// it's not constexpr.
374
- if (CD && CD->isInheritingConstructor ())
369
+ if (CD && CD->isInheritingConstructor ()) {
375
370
S.FFDiag (Loc, diag::note_constexpr_invalid_inhctor, 1 )
376
371
<< CD->getInheritedConstructor ().getConstructor ()->getParent ();
377
- else
372
+ S.Note (DiagDecl->getLocation (), diag::note_declared_at);
373
+ } else {
374
+ // Don't emit anything if the function isn't defined and we're checking
375
+ // for a constant expression. It might be defined at the point we're
376
+ // actually calling it.
377
+ if (!DiagDecl->isDefined () && S.checkingPotentialConstantExpression ())
378
+ return false ;
379
+
378
380
S.FFDiag (Loc, diag::note_constexpr_invalid_function, 1 )
379
381
<< DiagDecl->isConstexpr () << (bool )CD << DiagDecl;
380
- S.Note (DiagDecl->getLocation (), diag::note_declared_at);
382
+ S.Note (DiagDecl->getLocation (), diag::note_declared_at);
383
+ }
381
384
} else {
382
385
S.FFDiag (Loc, diag::note_invalid_subexpr_in_const_expr);
383
386
}
0 commit comments