diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-10 14:38:10 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-10 18:10:57 +0000 |
commit | f10e695fc508c472c77e968e644f710806f82f54 (patch) | |
tree | 1628784a0b83981ea01f024e5989832edf447a1a /gcc/rust/parse/rust-parse-impl.h | |
parent | ae273ffac99cb75d832a11a83fd63291bb74cbdc (diff) | |
download | gcc-f10e695fc508c472c77e968e644f710806f82f54.zip gcc-f10e695fc508c472c77e968e644f710806f82f54.tar.gz gcc-f10e695fc508c472c77e968e644f710806f82f54.tar.bz2 |
Return expressions can be empty which us unit-type
The parser has the same bug as in #225 for break expressions. This
tidies up the type resolver and GENERIC translation to handle the
case where there is no return expression as well.
Fixes #226
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 18e6983..fcb3d18 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -7400,8 +7400,10 @@ Parser<ManagedTokenSource>::parse_return_expr ( } // parse expression to return, if it exists - std::unique_ptr<AST::Expr> returned_expr = parse_expr (); - // FIXME: ensure this doesn't ruin the middle of any expressions or anything + ParseRestrictions restrictions; + restrictions.expr_can_be_null = true; + std::unique_ptr<AST::Expr> returned_expr + = parse_expr (std::vector<AST::Attribute> (), restrictions); return std::unique_ptr<AST::ReturnExpr> ( new AST::ReturnExpr (locus, std::move (returned_expr), |