Skip to content

Commit 6876514

Browse files
committed
Fix assertion failure mangling an unresolved template argument that
corresponds to a parameter pack. Fixes #67244.
1 parent b7e9ef7 commit 6876514

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5788,13 +5788,14 @@ struct CXXNameMangler::TemplateArgManglingInfo {
57885788
"no parameter for argument");
57895789
Param = ResolvedTemplate->getTemplateParameters()->getParam(ParamIdx);
57905790

5791-
// If we reach an expanded parameter pack whose argument isn't in pack
5792-
// form, that means Sema couldn't figure out which arguments belonged to
5793-
// it, because it contains a pack expansion. Track the expanded pack for
5794-
// all further template arguments until we hit that pack expansion.
5791+
// If we reach a parameter pack whose argument isn't in pack form, that
5792+
// means Sema couldn't or didn't figure out which arguments belonged to
5793+
// it, because it contains a pack expansion or because Sema bailed out of
5794+
// computing parameter / argument correspondence before this point. Track
5795+
// the pack as the corresponding parameter for all further template
5796+
// arguments until we hit a pack expansion, at which point we don't know
5797+
// the correspondence between parameters and arguments at all.
57955798
if (Param->isParameterPack() && Arg.getKind() != TemplateArgument::Pack) {
5796-
assert(getExpandedPackSize(Param) &&
5797-
"failed to form pack argument for parameter pack");
57985799
UnresolvedExpandedPack = Param;
57995800
}
58005801
}

clang/test/CodeGenCXX/mangle-concept.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,11 @@ namespace test7 {
220220
}
221221
template void f<int>();
222222
}
223+
224+
namespace gh67244 {
225+
template<typename T, typename ...Ts> constexpr bool B = true;
226+
template<typename T, typename ...Ts> concept C = B<T, Ts...>;
227+
template<C<int, float> T> void f(T) {}
228+
// CHECK: define {{.*}} @_ZN7gh672441fITkNS_1CIifEEiEEvT_(
229+
template void f(int);
230+
}

0 commit comments

Comments
 (0)