Commit 6e4f1148 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/85194 (ICE with structured binding in broken for-loop)

	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
parent 78c3f9be
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.
......
......@@ -12983,8 +12983,14 @@ cp_parser_simple_declaration (cp_parser* parser,
/* 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.
......
// 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 }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment