diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -71,6 +71,9 @@ - Fix `#57008 `_ - Builtin C++ language extension type traits instantiated by a template with unexpected number of arguments cause an assertion fault. +- Fix multi-level pack expansion of undeclared function parameters. + This fixes `Issue 56094 `_. + Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -5792,6 +5792,7 @@ = dyn_cast(OldType)) { // We have a function parameter pack that may need to be expanded. QualType Pattern = Expansion->getPattern(); + NumExpansions = Expansion->getNumExpansions(); SmallVector Unexpanded; getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp --- a/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -469,3 +469,25 @@ bar(b); } } + +namespace pr56094 { +template struct D { + template using B = int(int (*...p)(T, U)); + // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}} + template D(B *); + // expected-note@-1 {{in instantiation of template type alias 'B' requested here}} +}; +using t1 = D::B; +// expected-note@-1 {{in instantiation of template class 'pr56094::D' requested here}} + +template struct F {}; +template struct G {}; +template struct E { + template using B = G...>; + // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}} + template E(B *); + // expected-note@-1 {{in instantiation of template type alias 'B' requested here}} +}; +using t2 = E::B; +// expected-note@-1 {{in instantiation of template class 'pr56094::E' requested here}} +} // namespace pr56094