Skip to content

Commit 74e4444

Browse files
committed
pack_size() could be more than 1
1 parent eba7928 commit 74e4444

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,17 +1072,19 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
10721072
AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
10731073
/*NumberOfArgumentsMustMatch=*/false);
10741074

1075-
static auto IsNonDeducedArgument = [&](const DeducedTemplateArgument &TA) {
1076-
// The following cases indicate the template argument is non-deducible:
1077-
// 1. The result is null. E.g. When it comes from a default template
1078-
// argument that doesn't appear in the alias declaration.
1079-
// 2. The template parameter is a pack and that cannot be deduced from
1080-
// the arguments within the alias declaration.
1081-
// Non-deducible template parameters will persist in the transformed
1082-
// deduction guide.
1083-
return TA.isNull() || (TA.getKind() == TemplateArgument::Pack &&
1084-
TA.pack_size() == 1 && TA.pack_begin()->isNull());
1085-
};
1075+
static std::function<bool(const TemplateArgument &TA)> IsNonDeducedArgument =
1076+
[](const TemplateArgument &TA) {
1077+
// The following cases indicate the template argument is non-deducible:
1078+
// 1. The result is null. E.g. When it comes from a default template
1079+
// argument that doesn't appear in the alias declaration.
1080+
// 2. The template parameter is a pack and that cannot be deduced from
1081+
// the arguments within the alias declaration.
1082+
// Non-deducible template parameters will persist in the transformed
1083+
// deduction guide.
1084+
return TA.isNull() ||
1085+
(TA.getKind() == TemplateArgument::Pack &&
1086+
llvm::any_of(TA.pack_elements(), IsNonDeducedArgument));
1087+
};
10861088

10871089
SmallVector<TemplateArgument> DeducedArgs;
10881090
SmallVector<unsigned> NonDeducedTemplateParamsInFIndex;

clang/test/SemaCXX/ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ template <class... ArgTs>
6767
A(ArgTs...) -> A<typename ArgTs::value_type...>;
6868

6969
template <class... Ts>
70-
using AA = A<Ts...>;
70+
using AA = A<Ts..., Ts...>;
7171

7272
AA a{};
7373

0 commit comments

Comments
 (0)