C++ PATCH for C++17 selection statements with initializer

Jason Merrill jason@redhat.com
Wed Oct 5 14:48:00 GMT 2016


On Wed, Oct 5, 2016 at 9:14 AM, Marek Polacek <polacek@redhat.com> wrote:
> +/* Return true if we're looking at (init; cond), false otherwise.  */
> +
> +static bool
> +cp_parser_init_statement_p (cp_parser *parser)
> +{
> +  unsigned paren_depth = 0;
> +  unsigned brace_depth = 0;

Do we really need another one of these token scanning functions?
Can't you write this in terms of
cp_parser_skip_to_closing_parenthesis?

> +       /* Parse the optional init-statement.  */
> +       tree decl;
> +       cp_lexer_save_tokens (parser->lexer);
> +       const bool init_stmt_p = cp_parser_init_statement_p (parser);
> +       /* Roll back the tokens we skipped.  */
> +       cp_lexer_rollback_tokens (parser->lexer);

The save/rollback should be in the the predicate function, not the caller.

Jason



More information about the Gcc-patches mailing list