aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse-impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index c4cfbe2..4ebdcf0 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -11728,10 +11728,17 @@ Parser<ManagedTokenSource>::parse_stmt_or_expr_without_block ()
// must be expression statement
lexer.skip_token ();
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (expr),
- t->get_locus ()));
- return ExprOrStmt (std::move (stmt));
+ if (expr)
+ {
+ std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
+ new AST::ExprStmtWithoutBlock (std::move (expr),
+ t->get_locus ()));
+ return ExprOrStmt (std::move (stmt));
+ }
+ else
+ {
+ return ExprOrStmt::create_error ();
+ }
}
// return expression