================
@@ -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()) {
----------------
Sirraide wrote:

Can you move this entire condition into a helper function somewhere (maybe make 
it a member of `State`)?

https://github.com/llvm/llvm-project/pull/173537
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to