Skip to content

Commit b2d554d

Browse files
committed
add a release note and comments
1 parent 3dd62b0 commit b2d554d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

829830
Bug Fixes to AST Handling
830831
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplateVariadic.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)