PR c++/85194
* parser.c (cp_parser_simple_declaration): For structured bindings,
if *maybe_range_for_decl is NULL after parsing it, set it to
error_mark_node.
* g++.dg/cpp1z/decomp43.C: New test.
From-SVN: r259252
+2018-04-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/85194
+ * parser.c (cp_parser_simple_declaration): For structured bindings,
+ if *maybe_range_for_decl is NULL after parsing it, set it to
+ error_mark_node.
+
2018-04-09 Jason Merrill <jason@redhat.com>
PR c++/85256 - ICE capturing pointer to VLA.
/* The next token should be either a `,' or a `;'. */
cp_token *token = cp_lexer_peek_token (parser->lexer);
/* If it's a `;', we are done. */
- if (token->type == CPP_SEMICOLON || maybe_range_for_decl)
+ if (token->type == CPP_SEMICOLON)
goto finish;
+ else if (maybe_range_for_decl)
+ {
+ if (*maybe_range_for_decl == NULL_TREE)
+ *maybe_range_for_decl = error_mark_node;
+ goto finish;
+ }
/* Anything else is an error. */
else
{
2018-04-09 Jakub Jelinek <jakub@redhat.com>
+ PR c++/85194
+ * g++.dg/cpp1z/decomp43.C: New test.
+
PR rtl-optimization/80463
* g++.dg/pr80463.C: Add -w to dg-options.
--- /dev/null
+// PR c++/85194
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+struct A { int i; };
+
+A x[2];
+
+void
+foo ()
+{
+ for (auto [i] = A () : x) // { dg-error "initializer in range-based 'for' loop" }
+ ; // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+}