diff options
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 12 | ||||
-rw-r--r-- | gcc/rust/parse/rust-parse.h | 1 |
2 files changed, 9 insertions, 4 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index d391304..18e6983 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -7437,7 +7437,10 @@ Parser<ManagedTokenSource>::parse_break_expr ( } // parse break return expression if it exists - std::unique_ptr<AST::Expr> return_expr = parse_expr (); + ParseRestrictions restrictions; + restrictions.expr_can_be_null = true; + std::unique_ptr<AST::Expr> return_expr + = parse_expr (std::vector<AST::Attribute> (), restrictions); return std::unique_ptr<AST::BreakExpr> ( new AST::BreakExpr (locus, std::move (label), std::move (return_expr), @@ -12461,9 +12464,10 @@ Parser<ManagedTokenSource>::null_denotation ( // array definition expr (not indexing) return parse_array_expr (std::move (outer_attrs), true); default: - rust_error_at (tok->get_locus (), - "found unexpected token %qs in null denotation", - tok->get_token_description ()); + if (!restrictions.expr_can_be_null) + rust_error_at (tok->get_locus (), + "found unexpected token %qs in null denotation", + tok->get_token_description ()); return nullptr; } } diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h index 873b55e9..e691c9e 100644 --- a/gcc/rust/parse/rust-parse.h +++ b/gcc/rust/parse/rust-parse.h @@ -82,6 +82,7 @@ struct ParseRestrictions /* Whether the expression was entered from a unary expression - prevents stuff * like struct exprs being parsed from a dereference. */ bool entered_from_unary = false; + bool expr_can_be_null = false; }; // Parser implementation for gccrs. |