================ @@ -888,31 +890,40 @@ 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; + } + } + + if (NumExpansions && CurNumExpansions && + *NumExpansions != *CurNumExpansions) { + if (CurMaximumOfLeastExpansions && + *CurMaximumOfLeastExpansions <= *NumExpansions) { + ShouldExpand = false; ---------------- cor3ntin wrote:
Can you add a comment? 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