On 06/30/2017 01:24 PM, Jakub Jelinek wrote:

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.

ok, but ...

--- 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 }
  }

The .-1 on the final error is actually about the previous statement, not the line it's lexically on. Could you put it on a line on its own, while you're there?

--
Nathan Sidwell

Reply via email to