Skip to content

Commit 144f3c9

Browse files
committed
Let ... expand NTTP constraints
1 parent 111d100 commit 144f3c9

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6376,7 +6376,7 @@ ASTContext::getAutoType(QualType DeducedType, AutoTypeKeyword Keyword,
63766376
}
63776377

63786378
QualType ASTContext::getUnconstrainedType(QualType T) const {
6379-
QualType CanonT = T.getCanonicalType();
6379+
QualType CanonT = T.getNonPackExpansionType().getCanonicalType();
63806380

63816381
// Remove a type-constraint from a top-level auto or decltype(auto).
63826382
if (auto *AT = CanonT->getAs<AutoType>()) {

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ bool Sema::AttachTypeConstraint(AutoTypeLoc TL,
12281228
NonTypeTemplateParmDecl *NewConstrainedParm,
12291229
NonTypeTemplateParmDecl *OrigConstrainedParm,
12301230
SourceLocation EllipsisLoc) {
1231-
if (NewConstrainedParm->getType() != TL.getType() ||
1231+
if (NewConstrainedParm->getType().getNonPackExpansionType() != TL.getType() ||
12321232
TL.getAutoKeyword() != AutoTypeKeyword::Auto) {
12331233
Diag(NewConstrainedParm->getTypeSourceInfo()->getTypeLoc().getBeginLoc(),
12341234
diag::err_unsupported_placeholder_constraint)
@@ -1530,17 +1530,9 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
15301530
Param->setAccess(AS_public);
15311531

15321532
if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc())
1533-
if (TL.isConstrained()) {
1534-
if (const ASTTemplateArgumentListInfo *ArgumentList =
1535-
TL.getConceptReference()->getTemplateArgsAsWritten())
1536-
for (const TemplateArgumentLoc &Loc : ArgumentList->arguments()) {
1537-
Invalid |= DiagnoseUnexpandedParameterPack(
1538-
Loc, UnexpandedParameterPackContext::UPPC_TypeConstraint);
1539-
}
1540-
if (!Invalid &&
1541-
AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
1533+
if (TL.isConstrained())
1534+
if (AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
15421535
Invalid = true;
1543-
}
15441536

15451537
if (Invalid)
15461538
Param->setInvalidDecl();

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ class PackDeductionScope {
857857
if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
858858
TemplateParams->getParam(Index))) {
859859
if (!NTTP->isExpandedParameterPack())
860-
if (auto *Expansion = dyn_cast<PackExpansionType>(NTTP->getType()))
860+
if (auto *Expansion = dyn_cast<PackExpansionType>(
861+
S.Context.getUnconstrainedType(NTTP->getType())))
861862
ExtraDeductions.push_back(Expansion->getPattern());
862863
}
863864
// FIXME: Also collect the unexpanded packs in any type and template

0 commit comments

Comments
 (0)