@@ -7310,14 +7310,14 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) {
73107310 // array declarator.
73117311 if (!(Tok.isOneOf (tok::identifier, tok::ellipsis) &&
73127312 NextToken ().isOneOf (tok::comma, tok::r_square, tok::kw_alignas,
7313- tok::identifier, tok::l_square)) &&
7313+ tok::identifier, tok::l_square, tok::ellipsis )) &&
73147314 !(Tok.is (tok::r_square) &&
73157315 NextToken ().isOneOf (tok::equal, tok::l_brace))) {
73167316 PA.Revert ();
73177317 return ParseMisplacedBracketDeclarator (D);
73187318 }
73197319
7320- bool HasEllipsis = false ;
7320+ SourceLocation PrevEllipsisLoc ;
73217321 SmallVector<DecompositionDeclarator::Binding, 32 > Bindings;
73227322 while (Tok.isNot (tok::r_square)) {
73237323 if (!Bindings.empty ()) {
@@ -7332,9 +7332,8 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) {
73327332 Diag (Tok, diag::err_expected_comma_or_rsquare);
73337333 }
73347334
7335- // I don't know why this skipping was here
7336- // SkipUntil(tok::r_square, tok::comma, tok::identifier,
7337- // StopAtSemi | StopBeforeMatch);
7335+ SkipUntil ({tok::r_square, tok::comma, tok::identifier, tok::ellipsis},
7336+ StopAtSemi | StopBeforeMatch);
73387337 if (Tok.is (tok::comma))
73397338 ConsumeToken ();
73407339 else if (Tok.is (tok::r_square))
@@ -7345,17 +7344,18 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) {
73457344 if (isCXX11AttributeSpecifier ())
73467345 DiagnoseAndSkipCXX11Attributes ();
73477346
7348- SourceLocation EllipsisLoc = {} ;
7347+ SourceLocation EllipsisLoc;
73497348
73507349 if (Tok.is (tok::ellipsis)) {
73517350 if (!getLangOpts ().CPlusPlus26 )
7352- Diag (Tok, diag::warn_cxx2c_binding_pack );
7353- if (HasEllipsis ) {
7351+ Diag (Tok, diag::ext_cxx_binding_pack );
7352+ if (PrevEllipsisLoc. isValid () ) {
73547353 Diag (Tok, diag::err_binding_multiple_ellipses);
7354+ Diag (PrevEllipsisLoc, diag::note_previous_ellipsis);
73557355 break ;
73567356 }
7357- HasEllipsis = true ;
73587357 EllipsisLoc = Tok.getLocation ();
7358+ PrevEllipsisLoc = EllipsisLoc;
73597359 ConsumeToken ();
73607360 }
73617361
@@ -7368,6 +7368,13 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) {
73687368 SourceLocation Loc = Tok.getLocation ();
73697369 ConsumeToken ();
73707370
7371+ if (Tok.is (tok::ellipsis) && !PrevEllipsisLoc.isValid ()) {
7372+ DiagnoseMisplacedEllipsis (Tok.getLocation (), Loc,
7373+ EllipsisLoc.isValid (), true );
7374+ EllipsisLoc = Tok.getLocation ();
7375+ ConsumeToken ();
7376+ }
7377+
73717378 ParsedAttributes Attrs (AttrFactory);
73727379 if (isCXX11AttributeSpecifier ()) {
73737380 Diag (Tok, getLangOpts ().CPlusPlus26
0 commit comments