This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]