From: Pierre-Emmanuel Patry Date: Tue, 4 Apr 2023 09:24:44 +0000 (+0200) Subject: gccrs: ast: Fix tokenstream extern block statements X-Git-Tag: basepoints/gcc-15~2697 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2b0bc4a02379b93175d266306ebfa7900a84766;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index f965b4da9f39..b9473091d191 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 e5803350bba9..8ce25e10b93d 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);