================
@@ -1526,13 +1527,30 @@ bool CheckFunctionDecl(InterpState &S, CodePtr OpPC,
const FunctionDecl *FD) {
return diagnoseCallableDecl(S, OpPC, FD);
}
-static void compileFunction(InterpState &S, const Function *Func) {
- const FunctionDecl *Definition = Func->getDecl()->getDefinition();
- if (!Definition)
+static void compileFunction(InterpState &S, const Function *Func,
+ SourceLocation Loc) {
+
+ const FunctionDecl *Fn = Func->getDecl();
+
+ // [C++26] [temp.inst] p5
+ // [...] the function template specialization is implicitly instantiated
+ // when the specialization is referenced in a context that requires a
function
+ // definition to exist or if the existence of the definition affects the
+ // semantics of the program.
+ if (!Fn->isDefined() && Fn->isImplicitlyInstantiable() && Fn->isConstexpr()
&&
+ S.inConstantContext() && !S.TryConstantInitialization &&
+ !S.checkingPotentialConstantExpression()) {
----------------
erichkeane wrote:
I commented above, I think there is value in this being TWO functions for htis
condition.
ONE for hte `function` condition and one for the State. I'm not clever
enough/nor understand it well enough to come up with good names though. BUT
something where this is:
`if
(Fn->canBeAndNeedsConstexprEvaluationTimeInstantationOrSomethingOfThatSort() &&
S.evaluatingConstantExprSituationWhereWeProbablyShouldInstantiateConstexprFunctionsSometimesWhoKnowsWhatever())`
might be nice.
https://github.com/llvm/llvm-project/pull/173537
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits