The initializer for structured binding has to be one of:
= assignment-expression
( assignment-expression )
{ assignment-expression }
but cp_parser_initializer can parse other forms, with fewer or more
expressions in there. Some cases we caught with various cryptic errors
or pedwarns, but others we just ICEd on.
The following patch attempts to check this.
--- gcc/testsuite/g++.dg/cpp1z/decomp21.C.jj 2017-01-19 17:01:21.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp21.C 2017-06-30 11:07:04.786746784 +0200
@@ -12,5 +12,5 @@ foo ()
auto [ n, o, p ] { a };
auto [ q, r, t ] ( s );
auto [ u, v, w ] ( s, ); // { dg-error "expected primary-expression before '.' token" }
- auto [ x, y, z ] ( a ); // { dg-error "expression list treated as compound expression in initializer" "" { target *-*-* } .-1 }
+ auto [ x, y, z ] ( a ); // { dg-error "invalid initializer for structured binding" "" { target *-*-* } .-1 }
}