Skip to content

Commit

Permalink
Fix assertion failure mangling an unresolved template argument that
Browse files Browse the repository at this point in the history
corresponds to a parameter pack.

Fixes #67244.
  • Loading branch information
zygoloid committed Sep 24, 2023
1 parent b7e9ef7 commit 6876514
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5788,13 +5788,14 @@ struct CXXNameMangler::TemplateArgManglingInfo {
"no parameter for argument");
Param = ResolvedTemplate->getTemplateParameters()->getParam(ParamIdx);

// If we reach an expanded parameter pack whose argument isn't in pack
// form, that means Sema couldn't figure out which arguments belonged to
// it, because it contains a pack expansion. Track the expanded pack for
// all further template arguments until we hit that pack expansion.
// If we reach a parameter pack whose argument isn't in pack form, that
// means Sema couldn't or didn't figure out which arguments belonged to
// it, because it contains a pack expansion or because Sema bailed out of
// computing parameter / argument correspondence before this point. Track
// the pack as the corresponding parameter for all further template
// arguments until we hit a pack expansion, at which point we don't know
// the correspondence between parameters and arguments at all.
if (Param->isParameterPack() && Arg.getKind() != TemplateArgument::Pack) {
assert(getExpandedPackSize(Param) &&
"failed to form pack argument for parameter pack");
UnresolvedExpandedPack = Param;
}
}
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CodeGenCXX/mangle-concept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,11 @@ namespace test7 {
}
template void f<int>();
}

namespace gh67244 {
template<typename T, typename ...Ts> constexpr bool B = true;
template<typename T, typename ...Ts> concept C = B<T, Ts...>;
template<C<int, float> T> void f(T) {}
// CHECK: define {{.*}} @_ZN7gh672441fITkNS_1CIifEEiEEvT_(
template void f(int);
}

0 comments on commit 6876514

Please sign in to comment.