diff options
author | Matthew Jasper <mjjasper1@gmail.com> | 2023-05-10 02:08:37 +0100 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-05-15 14:48:41 +0000 |
commit | 136ef0912e962052446de93d822c4661578d805a (patch) | |
tree | db2ea85cd61fb84218a1bb418b1bd6d70d502d40 /gcc/gimple-range-edge.cc | |
parent | 4cd88c4cd60bce7a2fd14191334a56ab08ea5181 (diff) | |
download | gcc-136ef0912e962052446de93d822c4661578d805a.zip gcc-136ef0912e962052446de93d822c4661578d805a.tar.gz gcc-136ef0912e962052446de93d822c4661578d805a.tar.bz2 |
gccrs: Fix parsing of block expressions followed by `.`
`{ ... }.f;` is parsed as a single statement in rust. This means that we can't
determine whether an expression statement will need a semicolon terminator
until we finish parsing it. To handle this we change expression parsing to
check for this case by inspecting the expression returned from null_denotation
and looking ahead for a `.` or `?` token.
gcc/rust/ChangeLog:
* ast/rust-ast.h (Expr::as_expr_without_block): Remove.
(Expr::set_outer_attrs): Make public in base class.
* expand/rust-macro-expand.cc:
Add fixme comment for pre-existing bug.
* hir/tree/rust-hir.h: Remove Expr::as_expr_without_block.
* parse/rust-parse-impl.h (Parser::parse_lifetime): Use lifetime_from_token.
(Parser::lifetime_from_token): New method.
(Parser::null_denotation): Handle labelled loop expressions and for loop expressions.
(Parser::parse_loop_label): Make initial token a parameter.
(Parser::parse_labelled_loop_expr): Likewise.
(Parser::parse_for_loop_expr): Allow FOR token to already be skipped.
(Parser::parse_expr): Handle expr_can_be_stmt.
(Parser::parse_expr_with_block): Remove.
(Parser::parse_expr_stmt_with_block): Remove.
(Parser::parse_expr_stmt_without_block): Remove.
(Parser::parse_expr_without_block): Remove.
(Parser::parse_stmt_or_expr_with_block): Remove.
(Parser::parse_expr_stmt): Use parse_expr directly.
(Parser::parse_match_expr): Likewise.
(Parser::parse_stmt): Use parse_expr_stmt in more cases.
(Parser::parse_stmt_or_expr):
Rename from parse_stmt_or_expr_without_block, use parse_expr directly.
(Parser::parse_block_expr): Update error message.
* parse/rust-parse.h: Update declarations.
gcc/testsuite/ChangeLog:
* rust/compile/for_expr.rs: New test.
* rust/compile/issue-407-2.rs: Update compiler output.
* rust/compile/issue-407.rs: Update compiler output.
* rust/compile/issue-867.rs: Update compiler output.
* rust/compile/issue-2189.rs: New test.
* rust/compile/macro_call_statement.rs: New test.
* rust/compile/stmt_with_block_dot.rs: New test.
* rust/compile/torture/loop8.rs: New test.
Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>
Diffstat (limited to 'gcc/gimple-range-edge.cc')
0 files changed, 0 insertions, 0 deletions