[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 26 02:17:06 PDT 2024
================
@@ -507,10 +507,62 @@ static TemplateDeductionResult DeduceNonTypeTemplateArgument(
S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
}
+static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A,
+ TemplateArgument Default) {
+ switch (A->getKind()) {
+ case Decl::TemplateTypeParm: {
+ auto *T = cast<TemplateTypeParmDecl>(A);
+ // FIXME: DefaultArgument can't represent a pack.
+ if (T->isParameterPack())
+ return A;
+ auto *R = TemplateTypeParmDecl::Create(
+ S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(),
+ T->getDepth(), T->getIndex(), T->getIdentifier(),
+ T->wasDeclaredWithTypename(), /*ParameterPack=*/false,
+ T->hasTypeConstraint());
+ R->setDefaultArgument(
+ S.Context.getTrivialTypeSourceInfo(Default.getAsType()));
+ if (R->hasTypeConstraint()) {
+ auto *C = R->getTypeConstraint();
+ R->setTypeConstraint(C->getConceptReference(),
+ C->getImmediatelyDeclaredConstraint());
----------------
mizvekov wrote:
It's the same tests I linked in the other thread: https://github.com/llvm/llvm-project/blob/15f02723d49be9a828fbf072966a225babd60457/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp#L48
https://github.com/llvm/llvm-project/pull/89807
More information about the cfe-commits
mailing list