From e2b0bc4a02379b93175d266306ebfa7900a84766 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Tue, 4 Apr 2023 11:24:44 +0200 Subject: gccrs: ast: Fix tokenstream extern block statements 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 --- gcc/rust/ast/rust-ast-tokenstream.cc | 3 +-- gcc/rust/ast/rust-ast-tokenstream.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index f965b4d..b947309 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.cc +++ b/gcc/rust/ast/rust-ast-tokenstream.cc @@ -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 diff --git a/gcc/rust/ast/rust-ast-tokenstream.h b/gcc/rust/ast/rust-ast-tokenstream.h index e580335..8ce25e1 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.h +++ b/gcc/rust/ast/rust-ast-tokenstream.h @@ -85,7 +85,7 @@ private: * collection to print only the delimiters with no new line inside. */ template - void visit_items_as_block (T &collection, std::vector trailing, + void visit_items_as_block (T &collection, std::vector trailing = {}, TokenId left_brace = LEFT_CURLY, TokenId right_brace = RIGHT_CURLY); -- cgit v1.1