Hi,
On 18/05/2018 16:45, Jason Merrill wrote:
I guess it's desirable to also give this error when the declarator is
followed by ) or ; rather than other tokens that could be more
expression (like in A(a).x in the comment).
I can certainly try to implement this, maybe just something minimal to begin
with, as you say ) or ; alone would be safe and would already take care of
all the tests I have around.
Certainly, unconditionally deferring at that point to cp_parser_expression
leads to *very* bad error-recovery. For fun, try with 8.1.0:
void foo()
{
for (;void bar(););
}
and it gets worse.
It would also need to be only for a non-parenthesized declarator,
which can't be an expression; a parenthesized declarator can be, as in
this well-formed testcase:
bool (bar()) { return 0; } // declaration
void foo()
{
for (;bool (bar());); // expression
}
Thanks for clarifying that. I'll make sure we have such testcases.
Interestingly, if we aren't careful about that in the new code,
libstdc++-v3 doesn't even build, eh!
Paolo.