Commit e4658c7d by Jakub Jelinek

c++: Fix pasto in structured binding diagnostics [PR94571]

This snippet has been copied from the non-structured binding declaration
parsing later in the function, and while for non-structured bindings
it can be followed by comma or semicolon, structured bindings may be
only followed by semicolon.

Or, do we want to have a different message for the case when there is
a comma (and keep this corrected one only if there is something else)
that would explain better what is the bug (or add a fix-it hint)?
Marek said in the PR that clang++ reports
error: decomposition declaration must be the only declaration in its group

There is another thing Marek noted (though, something for different spot),
that diagnostic for auto x(1), [e,f] = test2; could also use a clearer
wording like the above (or a fix-it hint), but the question is if we should
assume [ after , as a structured binding or if we should do some tentative
parsing first to figure out if it looks like a structured binding.

2020-04-16  Jakub Jelinek  <jakub@redhat.com>

	PR c++/94571
	* parser.c (cp_parser_simple_declaration): Fix up a pasto in
	diagnostics.

	* g++.dg/cpp1z/decomp51.C: New test.
parent b8a1750a
2020-04-16 Jakub Jelinek <jakub@redhat.com>
PR c++/94571
* parser.c (cp_parser_simple_declaration): Fix up a pasto in
diagnostics.
2020-04-15 Jakub Jelinek <jakub@redhat.com> 2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR c/94593 PR c/94593
......
...@@ -13675,7 +13675,7 @@ cp_parser_simple_declaration (cp_parser* parser, ...@@ -13675,7 +13675,7 @@ cp_parser_simple_declaration (cp_parser* parser,
if ((decl != error_mark_node if ((decl != error_mark_node
&& DECL_INITIAL (decl) != error_mark_node) && DECL_INITIAL (decl) != error_mark_node)
|| cp_parser_uncommitted_to_tentative_parse_p (parser)) || cp_parser_uncommitted_to_tentative_parse_p (parser))
cp_parser_error (parser, "expected %<,%> or %<;%>"); cp_parser_error (parser, "expected %<;%>");
/* Skip tokens until we reach the end of the statement. */ /* Skip tokens until we reach the end of the statement. */
cp_parser_skip_to_end_of_statement (parser); cp_parser_skip_to_end_of_statement (parser);
/* If the next token is now a `;', consume it. */ /* If the next token is now a `;', consume it. */
2020-04-16 Jakub Jelinek <jakub@redhat.com>
PR c++/94571
* g++.dg/cpp1z/decomp51.C: New test.
2020-04-15 Uroš Bizjak <ubizjak@gmail.com> 2020-04-15 Uroš Bizjak <ubizjak@gmail.com>
PR target/94603 PR target/94603
......
// PR c++/94571
// { dg-do compile { target c++17 } }
void
foo ()
{
int e[2], f[2];
auto [a,b] = e, [c,d] = f; // { dg-error "expected ';' before ',' token" }
}
void
bar ()
{
int e[2];
auto [a, b] = e ); // { dg-error "expected ';' before '\\\)' token" }
}
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