]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Parse named variadic parameters
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 23 Oct 2023 11:41:35 +0000 (13:41 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:13:12 +0000 (19:13 +0100)
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>
gcc/rust/parse/rust-parse-impl.h

index 007b2bfaba04a6ca363adbfbb33ee4d75ed41392..554893ca523a6f3182dd39cafe4d0734581c3a93 100644 (file)
@@ -5970,7 +5970,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);
@@ -6002,6 +6002,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)