This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for C++17 selection statements with initializer
- From: Jason Merrill <jason at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 5 Oct 2016 10:48:19 -0400
- Subject: Re: C++ PATCH for C++17 selection statements with initializer
- Authentication-results: sourceware.org; auth=none
- References: <20161005131425.GQ3223@redhat.com>
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