================
@@ -690,6 +690,23 @@ SmallVector<unsigned> 
TemplateParamsReferencedInTemplateArgumentList(
   SemaRef.MarkUsedTemplateParameters(
       DeducedArgs, TemplateParamsList->getDepth(), ReferencedTemplateParams);
 
+  auto MarkDefaultArgs = [&](auto *Param) {
+    if (!Param || !Param->hasDefaultArgument())
+      return;
+    SemaRef.MarkUsedTemplateParameters(
+        Param->getDefaultArgument().getArgument(),
+        TemplateParamsList->getDepth(), ReferencedTemplateParams);
+  };
+
+  for (unsigned Index = 0; Index < TemplateParamsList->size(); ++Index) {
+    if (!ReferencedTemplateParams[Index])
+      continue;
+    auto *Param = TemplateParamsList->getParam(Index);
+    MarkDefaultArgs(dyn_cast<TemplateTypeParmDecl>(Param));
+    MarkDefaultArgs(dyn_cast<NonTypeTemplateParmDecl>(Param));
+    MarkDefaultArgs(dyn_cast<TemplateTemplateParmDecl>(Param));
+  }
+
----------------
zyn0217 wrote:

> I wonder if we are missing a step to get the converted template argument 
> list, and should be calling this with that instead of the deduced arguments 
> directly.

The fact that makes me think it sensible is, in the later template parameter 
transform, we do retain/tranaform the default arguments. That means, the 
transformed template parameters which has default arguments could end up 
referring to anything that won't otherwise appear in the synthesized template 
parameter list. And this is exactly where the issue raised.

Re the ConvertDeducedTemplateArguments, i think we probably want it, but I 
couldn't immediately recall what job it does to handle default arguments.

https://github.com/llvm/llvm-project/pull/134807
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to