Skip to content

Commit

Permalink
Parse named variadic parameters
Browse files Browse the repository at this point in the history
Add ability to parse named variadic parameters in extern c functions.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_named_function_param): Add
	new parsing ability.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
  • Loading branch information
P-E-P committed Nov 6, 2023
1 parent ecd7c21 commit 4be6536
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5960,7 +5960,7 @@ Parser<ManagedTokenSource>::parse_named_function_param ()
AST::AttrVec outer_attrs = parse_outer_attributes ();
location_t locus = lexer.peek_token ()->get_locus ();

if (lexer.peek_token ()->get_id () == ELLIPSIS)
if (lexer.peek_token ()->get_id () == ELLIPSIS) // Unnamed variadic
{
lexer.skip_token (); // Skip ellipsis
return AST::NamedFunctionParam (std::move (outer_attrs), locus);
Expand Down Expand Up @@ -5992,6 +5992,13 @@ Parser<ManagedTokenSource>::parse_named_function_param ()
return AST::NamedFunctionParam::create_error ();
}

if (lexer.peek_token ()->get_id () == ELLIPSIS) // Named variadic
{
lexer.skip_token (); // Skip ellipsis
return AST::NamedFunctionParam (std::move (name), std::move (outer_attrs),
locus);
}

// parse (required) type
std::unique_ptr<AST::Type> param_type = parse_type ();
if (param_type == nullptr)
Expand Down

0 comments on commit 4be6536

Please sign in to comment.