[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 21 08:00:42 PDT 2024
================
@@ -1107,8 +1172,32 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
Sema::CodeSynthesisContext::BuildingDeductionGuides)) {
auto *GG = cast<CXXDeductionGuideDecl>(FPrime);
- Expr *IsDeducible = buildIsDeducibleConstraint(
- SemaRef, AliasTemplate, FPrime->getReturnType(), FPrimeTemplateParams);
+ TypeSourceInfo *TSI = GG->getTypeSourceInfo();
+ QualType ReturnType = FPrime->getReturnType();
+ TemplateDecl *DeducedTemplate =
+ FromInheritedCtor ? FromInheritedCtor->DerivedClassTemplate
+ : AliasTemplate;
+ if (FromInheritedCtor) {
+ TSI = buildInheritedConstructorDeductionGuideType(
+ SemaRef, *FromInheritedCtor, TSI);
+ if (!TSI)
+ return nullptr;
+ ReturnType = TSI->getType()
+ .getTypePtr()
+ ->getAs<FunctionProtoType>()
+ ->getReturnType();
+ }
+
+ // We omit the deducible constraint for inherited constructor deduction
+ // guides because they would take precedence over the derived class' own
+ // deduction guides due to [over.match.best.general]p2.5 and
+ // [temp.func.order]p6.4 If the alias were not deducible in this case, the
+ // deduction guide would already not be deducible due to the partial
+ // specialization `CC<>` failing substitution.
----------------
cor3ntin wrote:
Did we decide this is correct? Should it not be a conjunction?
https://github.com/llvm/llvm-project/pull/98788
More information about the cfe-commits
mailing list