]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: ast: Fix tokenstream extern block statements
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 4 Apr 2023 09:24:44 +0000 (11:24 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:28:43 +0000 (18:28 +0100)
The visitor created some additional semicolon between statements in
extern blocks, this lead to empty statement.

gcc/rust/ChangeLog:

* ast/rust-ast-tokenstream.cc (TokenStream::visit): Remove
additional semicolon output.
* ast/rust-ast-tokenstream.h: Change block visitor prototype
with a default value for trailing tokens.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-tokenstream.cc
gcc/rust/ast/rust-ast-tokenstream.h

index f965b4da9f3910923147ab0280d58129f4480bf3..b9473091d19177be95891d1554ed44e070cf3e9d 100644 (file)
@@ -2243,8 +2243,7 @@ TokenStream::visit (ExternBlock &block)
        Rust::Token::make_string (Location (), std::move (abi)));
     }
 
-  visit_items_as_block (block.get_extern_items (),
-                       {Rust::Token::make (SEMICOLON, Location ())});
+  visit_items_as_block (block.get_extern_items ());
 }
 
 static std::pair<TokenId, TokenId>
index e5803350bba9bbb0e3c35132ec626ee8e7ff8376..8ce25e10b93df5c2e4fe57b054c332dd28c4130c 100644 (file)
@@ -85,7 +85,7 @@ private:
    * collection to print only the delimiters with no new line inside.
    */
   template <typename T>
-  void visit_items_as_block (T &collection, std::vector<TokenPtr> trailing,
+  void visit_items_as_block (T &collection, std::vector<TokenPtr> trailing = {},
                             TokenId left_brace = LEFT_CURLY,
                             TokenId right_brace = RIGHT_CURLY);