Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 9 additions & 35 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1855,15 +1855,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi (
std::unique_ptr<AST::TokenTree> tree = parse_token_tree ();

if (tree == nullptr)
{
Error error (t->get_locus (),
"failed to parse token tree for macro invocation semi "
"- found %qs",
t->get_token_description ());
add_error (std::move (error));

return nullptr;
}
return nullptr;

token_trees.push_back (std::move (tree));

Expand Down Expand Up @@ -2999,8 +2991,9 @@ Parser<ManagedTokenSource>::parse_function (AST::Visibility vis,
else
{
std::unique_ptr<AST::BlockExpr> block_expr = parse_block_expr ();
if (block_expr != nullptr)
body = std::move (block_expr);
if (block_expr == nullptr)
return nullptr;
body = std::move (block_expr);
}

return std::unique_ptr<AST::Function> (
Expand Down Expand Up @@ -6226,10 +6219,6 @@ Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs,
expr = parse_expr ();
if (expr == nullptr)
{
Error error (lexer.peek_token ()->get_locus (),
"failed to parse expression in let statement");
add_error (std::move (error));

skip_after_semicolon ();
return nullptr;
}
Expand Down Expand Up @@ -7256,11 +7245,7 @@ Parser<ManagedTokenSource>::parse_block_expr (
ExprOrStmt expr_or_stmt = parse_stmt_or_expr ();
if (expr_or_stmt.is_error ())
{
Error error (
t->get_locus (),
"failed to parse statement or expression in block expression");
add_error (std::move (error));

skip_after_end_block ();
return nullptr;
}

Expand Down Expand Up @@ -7783,14 +7768,7 @@ Parser<ManagedTokenSource>::parse_if_expr (AST::AttrVec outer_attrs,
// parse required block expr
std::unique_ptr<AST::BlockExpr> if_body = parse_block_expr ();
if (if_body == nullptr)
{
Error error (lexer.peek_token ()->get_locus (),
"failed to parse if body block expression in if expression");
add_error (std::move (error));

// skip somewhere?
return nullptr;
}
return nullptr;

// branch to parse end or else (and then else, else if, or else if let)
if (lexer.peek_token ()->get_id () != ELSE)
Expand Down Expand Up @@ -8113,13 +8091,7 @@ Parser<ManagedTokenSource>::parse_loop_expr (AST::AttrVec outer_attrs,
// parse loop body, which is required
std::unique_ptr<AST::BlockExpr> loop_body = parse_block_expr ();
if (loop_body == nullptr)
{
Error error (lexer.peek_token ()->get_locus (),
"could not parse loop body in (infinite) loop expression");
add_error (std::move (error));

return nullptr;
}
return nullptr;

return std::unique_ptr<AST::LoopExpr> (
new AST::LoopExpr (std::move (loop_body), locus, std::move (label),
Expand Down Expand Up @@ -12198,6 +12170,8 @@ Parser<ManagedTokenSource>::parse_expr (int right_binding_power,
// parse null denotation (unary part of expression)
std::unique_ptr<AST::Expr> expr
= null_denotation ({}, null_denotation_restrictions);
if (expr == nullptr)
return nullptr;

return left_denotations (std::move (expr), right_binding_power,
std::move (outer_attrs), restrictions);
Expand Down
2 changes: 0 additions & 2 deletions gcc/testsuite/rust/compile/braced_macro_arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ macro_rules! m {

fn h(c: bool) {
match c {
// { dg-error "failed to parse statement or expression in block expression" "" { target *-*-* } .-1 }
true => m! {}
false => ()
// { dg-error "exprwithoutblock requires comma after match case expression in match arm \\(if not final case\\)" "" { target *-*-* } .-1 }
// { dg-error "unrecognised token .false. for start of item" "" { target *-*-* } .-2 }
};
}

Expand Down
6 changes: 0 additions & 6 deletions gcc/testsuite/rust/compile/issue-407-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
pub fn loopy() {
let mut a = 1;
loop {
// { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 }
if a < 40 {
// { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 }
a + = 1; // { dg-error "found unexpected token '=' in null denotation" }
// { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 }
// { dg-error {failed to parse if body block expression in if expression} "" { target *-*-* } .-2 }
// { dg-error {could not parse loop body in \(infinite\) loop expression} "" { target *-*-* } .-3 }
// { dg-error {unrecognised token 'integer literal' for start of item} "" { target *-*-* } .-4 }
} else {
break;
}
Expand Down
2 changes: 0 additions & 2 deletions gcc/testsuite/rust/compile/issue-407.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
fn test() {
let mut a = 1;
a + = 1; // { dg-error "found unexpected token '=' in null denotation" }
// { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 }
// { dg-error {unrecognised token 'integer literal' for start of item} "" { target *-*-* } .-2 }
}
2 changes: 0 additions & 2 deletions gcc/testsuite/rust/compile/issue-4162.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pub fn main() {
while let = 5
// { dg-error "should be at least 1 pattern" "" { target *-*-* } .-1 }
// { dg-error "failed to parse statement or expression in block expression" "" { target *-*-* } .-2 }
// { dg-error "unrecognised token .=. for start of item" "" { target *-*-* } .-3 }
{}
}

3 changes: 0 additions & 3 deletions gcc/testsuite/rust/compile/issue-867.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
fn main() {
let _ = 42;
let a = _ + 123; // { dg-error "use of '_' is not allowed on the right-side of an assignment" }
// { dg-error {failed to parse expression in let statement} "" { target *-*-* } .-1 }
// { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-2 }
// { dg-error {unrecognised token '\}' for start of item} "" { target *-*-* } .+1 }
}
2 changes: 0 additions & 2 deletions gcc/testsuite/rust/compile/raw_ref_op_invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ pub struct Toto {

pub fn test(mut toto: Toto) {
let _c = &raw toto.u; //{ dg-error "expecting .;. but .identifier. found" "" { target *-*-* } }
//{ dg-excess-errors "Additional errors for parent items" { target *-*-* } }

}