From 88e327fa0796891e5eb4509e9620885d80ffc253 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Mon, 23 Oct 2023 13:41:35 +0200 Subject: [PATCH] gccrs: Parse named variadic parameters 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 --- gcc/rust/parse/rust-parse-impl.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 007b2bfaba04..554893ca523a 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -5970,7 +5970,7 @@ Parser::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); @@ -6002,6 +6002,13 @@ Parser::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 param_type = parse_type (); if (param_type == nullptr) -- 2.47.2