File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -825,6 +825,7 @@ Bug Fixes to C++ Support
825825- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278)
826826- Fixed recognition of ``std::initializer_list `` when it's surrounded with ``extern "C++" `` and exported
827827 out of a module (which is the case e.g. in MSVC's implementation of ``std `` module). (#GH118218)
828+ - Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
828829
829830Bug Fixes to AST Handling
830831^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -859,6 +859,27 @@ bool Sema::CheckParameterPacksForExpansion(
859859 }
860860
861861 if (NewPackSize != *NumExpansions) {
862+ // In some cases, we might be handling packs with unexpanded template
863+ // arguments. For example, this can occur when substituting into a type
864+ // alias declaration that uses its injected template parameters as
865+ // arguments:
866+ //
867+ // template <class... Outer> struct S {
868+ // template <class... Inner> using Alias = S<void(Outer, Inner)...>;
869+ // };
870+ //
871+ // Consider an instantiation attempt like 'S<int>::Alias<Pack...>', where
872+ // Pack comes from another template parameter. 'S<int>' is first
873+ // instantiated, expanding the outer pack 'Outer' to <int>. The alias
874+ // declaration is accordingly substituted, leaving the template arguments
875+ // as unexpanded
876+ // '<Pack...>'.
877+ //
878+ // Since we have no idea of the size of '<Pack...>' until its expansion,
879+ // we shouldn't assume its pack size for validation. However if we are
880+ // certain that there are extra arguments beyond unexpanded packs, in
881+ // which case the pack size is already larger than the previous expansion,
882+ // we can complain that before instantiation.
862883 unsigned LeastNewPackSize = NewPackSize - PendingPackExpansionSize;
863884 if (PendingPackExpansionSize && LeastNewPackSize <= *NumExpansions) {
864885 ShouldExpand = false ;
You can’t perform that action at this time.
0 commit comments