diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-10-16 11:28:34 +0200 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-10-16 15:29:50 +0000 |
commit | 18154096774660d790daff8844cd773c2388f1c5 (patch) | |
tree | 3eede955a4818b931f49350ce647f9a2d64c7e93 | |
parent | 2b4eb390ec8f3a71c3389eb727b917f9eb4bae8f (diff) | |
download | gcc-18154096774660d790daff8844cd773c2388f1c5.zip gcc-18154096774660d790daff8844cd773c2388f1c5.tar.gz gcc-18154096774660d790daff8844cd773c2388f1c5.tar.bz2 |
Fix pub unit type parsing
Public unit types where not parsed correctly due to visibility specifiers
within parenthesis. Fixes #2648.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_visibility): Relax constraints
over public visibility return condition in order to accept pub unit
types.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index c2f35e2..cebf5b3 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2296,8 +2296,11 @@ Parser<ManagedTokenSource>::parse_visibility () auto vis_loc = lexer.peek_token ()->get_locus (); lexer.skip_token (); - // create simple pub visibility if no parentheses - if (lexer.peek_token ()->get_id () != LEFT_PAREN) + // create simple pub visibility if + // - found no parentheses + // - found unit type `()` + if (lexer.peek_token ()->get_id () != LEFT_PAREN + || lexer.peek_token (1)->get_id () == RIGHT_PAREN) { return AST::Visibility::create_public (vis_loc); // or whatever |