From 3448f0fa239430156d7ebbcab6cf1abb6095b242 Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Thu, 26 Jan 2023 22:59:49 -0500 Subject: Fix issue with parsing unsafe block expression statements gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_stmt): Handle unsafe expression statements. gcc/testsuite/ChangeLog: * rust/compile/issue-1422.rs: New test. Signed-off-by: Owen Avery --- gcc/rust/parse/rust-parse-impl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gcc/rust/parse/rust-parse-impl.h') diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 1e5b2dc..db32803d 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6131,7 +6131,15 @@ Parser::parse_stmt (ParseRestrictions restrictions) /* if any of these (should be all possible VisItem prefixes), parse a * VisItem can't parse item because would require reparsing outer * attributes */ - return parse_vis_item (std::move (outer_attrs)); + // may also be unsafe block + if (lexer.peek_token (1)->get_id () == LEFT_CURLY) + { + return parse_expr_stmt (std::move (outer_attrs), restrictions); + } + else + { + return parse_vis_item (std::move (outer_attrs)); + } break; case SUPER: case SELF: -- cgit v1.1