This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/31745: ICE on invalid use of namespace
On 17/05/07, Simon Martin <simartin@users.sourceforge.net> wrote:
>
> /* Skip the definition. */
> cp_lexer_consume_token (parser->lexer);
> cp_parser_skip_to_closing_brace (parser);
> + cp_parser_require (parser, CPP_CLOSE_BRACE, "`}'");
> cp_lexer_consume_token (parser->lexer);
> return;
This will not solve the ICE, because we'll still call
'cp_lexer_consume_token' at the EOF, so the same assertion will fail.
[snip]
Of course, if you meant to remove the call to 'cp_lexer_consume_token'
in this patch, then the ICE will indeed go away.
Yes, I meant removing the second cp_lexer_consume_token since
cp_parser_require already consumes the closing brace.
> or to test for it before consuming it:
>
> /* Skip the definition. */
> cp_lexer_consume_token (parser->lexer);
> cp_parser_skip_to_closing_brace (parser);
> - cp_lexer_consume_token (parser->lexer);
> + if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE))
> + cp_lexer_consume_token (parser->lexer);
> return;
> }
Well, after 'cp_parser_skip_to_closing_brace', we're either at a
CPP_CLOSE_BRACE or a CPP_EOF, so I guess that this test and the one I've
put in the patch have the same effect.
Can't we be at CPP_PRAGMA_EOL ? Look at the code of
cp_parser_skip_to_closing_brace. I still think that my proposal is
more robust. A more efficient version would be for
cp_parser_skip_to_closing_brace (parser) to return 1 if it found the
closing brace or 0 if it didn't. Then,
cp_lexer_consume_token (parser->lexer);
if (cp_parser_skip_to_closing_brace (parser))
cp_lexer_consume_token (parser->lexer);
return;
Thanks for your feedback.
Thanks to you for considering it.
Manuel.