Commit e428a9cf by Marek Polacek

c++: Fix ICE-on-invalid with broken attribute [PR93684]

We crash when parsing

  [[a::

because we see a CPP_SCOPE and then we're trying to consume a CPP_EOF
token.  So peek before consuming it.

	PR c++/93684 - ICE-on-invalid with broken attribute.
	* parser.c (cp_parser_std_attribute): Peek a token first before
	consuming it.

	* g++.dg/parse/attr4.C: New test.
parent 62fc0a6c
2020-02-12 Marek Polacek <polacek@redhat.com>
PR c++/93684 - ICE-on-invalid with broken attribute.
* parser.c (cp_parser_std_attribute): Peek a token first before
consuming it.
2020-02-11 Jason Merrill <jason@redhat.com>
PR c++/93675
......
......@@ -26720,7 +26720,7 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns)
"with scoped attribute token");
attr_ns = attr_id;
token = cp_lexer_consume_token (parser->lexer);
token = cp_lexer_peek_token (parser->lexer);
if (token->type == CPP_NAME)
attr_id = token->u.value;
else if (token->type == CPP_KEYWORD)
......@@ -26733,6 +26733,7 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns)
"expected an identifier for the attribute name");
return error_mark_node;
}
cp_lexer_consume_token (parser->lexer);
attr_ns = canonicalize_attr_name (attr_ns);
attr_id = canonicalize_attr_name (attr_id);
2020-02-12 Marek Polacek <polacek@redhat.com>
PR c++/93684 - ICE-on-invalid with broken attribute.
* g++.dg/parse/attr4.C: New test.
2020-02-12 Jakub Jelinek <jakub@redhat.com>
PR target/93670
......
// PR c++/93684 - ICE-on-invalid with broken attribute.
[[a:: // { dg-error "expected|expected" }
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