================ @@ -888,31 +896,47 @@ bool Sema::CheckParameterPacksForExpansion( // Pack comes from another template parameter. 'S<int>' is first // instantiated, expanding the outer pack 'Outer' to <int>. The alias // declaration is accordingly substituted, leaving the template arguments - // as unexpanded - // '<Pack...>'. + // as unexpanded '<Pack...>'. // // Since we have no idea of the size of '<Pack...>' until its expansion, // we shouldn't assume its pack size for validation. However if we are // certain that there are extra arguments beyond unexpanded packs, in // which case the pack size is already larger than the previous expansion, // we can complain that before instantiation. - unsigned LeastNewPackSize = NewPackSize - PendingPackExpansionSize; - if (PendingPackExpansionSize && LeastNewPackSize <= *NumExpansions) { + if (PendingPackExpansionSize && LeastNewPackSize <= *CurNumExpansions) { ShouldExpand = false; continue; } // C++0x [temp.variadic]p5: // All of the parameter packs expanded by a pack expansion shall have // the same number of arguments specified. - if (HaveFirstPack) - Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict) - << FirstPack.first << Name << *NumExpansions - << (LeastNewPackSize != NewPackSize) << LeastNewPackSize - << SourceRange(FirstPack.second) << SourceRange(ParmPack.second); - else - Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel) - << Name << *NumExpansions << (LeastNewPackSize != NewPackSize) - << LeastNewPackSize << SourceRange(ParmPack.second); + Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict) + << FirstPack.first << Name << *CurNumExpansions + << (LeastNewPackSize != NewPackSize) << LeastNewPackSize + << SourceRange(FirstPack.second) << SourceRange(Loc); + return true; + } + } + + // We have tried our best in the for loop to find out which outer pack + // expansion has a different length than the current one (by checking those + // Subst* nodes). However, if we fail to determine that, we'll have to + // complain the difference in a vague manner. ---------------- cor3ntin wrote:
```suggestion // We have tried our best in the for loop to find out which outer pack // expansion has a different length than the current one (by checking those // Subst* nodes). Here we display a more generic diagnostic if we could not find the outer pack. ``` https://github.com/llvm/llvm-project/pull/121044 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits