================ @@ -519,13 +571,45 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, return TemplateDeductionResult::Success; } - if (TemplateTemplateParmDecl *TempParam - = dyn_cast<TemplateTemplateParmDecl>(ParamDecl)) { + if (auto *TempParam = dyn_cast<TemplateTemplateParmDecl>(ParamDecl)) { // If we're not deducing at this depth, there's nothing to deduce. if (TempParam->getDepth() != Info.getDeducedDepth()) return TemplateDeductionResult::Success; - DeducedTemplateArgument NewDeduced(S.Context.getCanonicalTemplateName(Arg)); + auto NewDeduced = DeducedTemplateArgument(Arg); + // Provisional resolution for CWG2398: If Arg is also a template template + // param, and it names a template specialization, then we deduce a + // synthesized template template parameter based on A, but using the TS's + // arguments as defaults. + if (auto *TempArg = dyn_cast_or_null<TemplateTemplateParmDecl>( + Arg.getAsTemplateDecl())) { + assert(Arg.getKind() == TemplateName::Template); + assert(!TempArg->isExpandedParameterPack()); + + TemplateParameterList *As = TempArg->getTemplateParameters(); + if (DefaultArguments.size() != 0) { + assert(DefaultArguments.size() <= As->size()); + SmallVector<NamedDecl *, 4> Params(As->size()); + for (unsigned I = 0; I < DefaultArguments.size(); ++I) + Params[I] = + DeduceTemplateArguments(S, As->getParam(I), DefaultArguments[I]); + for (unsigned I = DefaultArguments.size(); I < As->size(); ++I) + Params[I] = As->getParam(I); + // FIXME: We could unique these, and also the parameters, but we don't + // expect programs to contain a large enough amount of these deductions + // for that to be worthwhile. ---------------- cor3ntin wrote:
Double checking: These parameters are only used for deduction, so not unique them would not affect type identity? https://github.com/llvm/llvm-project/pull/89807 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits