On Tue, Jan 21, 2025 at 12:04:36PM -0500, Jason Merrill wrote:
> > --- gcc/cp/parser.cc.jj 2025-01-17 19:27:34.052140136 +0100
> > +++ gcc/cp/parser.cc 2025-01-20 20:16:23.082876036 +0100
> > @@ -36632,14 +36632,22 @@ cp_parser_objc_message_args (cp_parser*
> > /* Handle non-selector arguments, if any. */
> > while (token->type == CPP_COMMA)
> > {
> > - tree arg;
> > -
> > cp_lexer_consume_token (parser->lexer);
> > - arg = cp_parser_assignment_expression (parser);
> > - addl_args
> > - = chainon (addl_args,
> > - build_tree_list (NULL_TREE, arg));
> > + if (cp_lexer_next_token_is (parser->lexer, CPP_EMBED))
> > + {
> > + tree raw_data = cp_lexer_peek_token (parser->lexer)->u.value;
> > + cp_lexer_consume_token (parser->lexer);
> > + for (tree argument : raw_data_range (raw_data))
> > + addl_args = chainon (addl_args,
> > + build_tree_list (NULL_TREE, argument));
>
> chainon of each byte of an #embed looks pretty inefficient, walking the full
> list for each new element. But OK.
Indeed, I've just used what it was doing without thinking too much about it,
sorry.
addl_args = tree_cons (NULL_TREE, arg, addl_args);
with addl_args = nreverse (addl_args); after the loop might be better,
can test that incrementally. sel_args is handled the same and should have
the same treatment.
Jakub