diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-05 18:24:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 18:24:20 +0000 |
commit | b96ab2e1a9539d1bb6a807774b9afe061de68fc4 (patch) | |
tree | 43c848ee7d2db2a30810adcdc613329d992f30a7 /gcc | |
parent | 082161121ca7fbf8fdafb0edcd86f2126df9f832 (diff) | |
parent | 09ec48621f7ae2cf4665942e95166fd3f840fb2b (diff) | |
download | gcc-b96ab2e1a9539d1bb6a807774b9afe061de68fc4.zip gcc-b96ab2e1a9539d1bb6a807774b9afe061de68fc4.tar.gz gcc-b96ab2e1a9539d1bb6a807774b9afe061de68fc4.tar.bz2 |
Merge #409
409: Fix crashing in assignment operation r=philberty a=teromene
This should fix #407
The output now looks like:
```
test1.rs:9:17: error: found unexpected token ‘=’ in null denotation
9 | a + = 1;
| ^
test1.rs:9:13: error: failed to parse expression for expression without block (pratt-parsed expression is null)
9 | a + = 1;
| ^
test1.rs:9:13: error: failed to parse statement or expression without block in block expression
test1.rs:9:19: error: failed to parse if body block expression in if expression
9 | a + = 1;
| ^
test1.rs:8:9: error: failed to parse expr with block in parsing expr statement
8 | if a < 40 {
| ^
test1.rs:8:9: error: failed to parse statement or expression without block in block expression
test1.rs:10:11: error: could not parse loop body in (infinite) loop expression
10 | } else {
| ^
test1.rs:7:5: error: failed to parse expr with block in parsing expr statement
7 | loop {
| ^
test1.rs:7:5: error: failed to parse statement or expression without block in block expression
test1.rs:14:5: error: unrecognised token ‘return’ for start of item
14 | return a;
| ^
test1.rs:14:5: error: failed to parse item in crate
```
Co-authored-by: Lyra <teromene@teromene.fr>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 3 | ||||
-rw-r--r-- | gcc/testsuite/rust.test/xfail_compile/issue-407.rs | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 6d38ace..5dcb458 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -11456,6 +11456,9 @@ Parser<ManagedTokenSource>::parse_stmt_or_expr_with_block ( std::vector<AST::Attribute> outer_attrs) { auto expr = parse_expr_with_block (std::move (outer_attrs)); + if (expr == nullptr) + return ExprOrStmt::create_error (); + auto tok = lexer.peek_token (); // tail expr in a block expr diff --git a/gcc/testsuite/rust.test/xfail_compile/issue-407.rs b/gcc/testsuite/rust.test/xfail_compile/issue-407.rs new file mode 100644 index 0000000..49ce91b --- /dev/null +++ b/gcc/testsuite/rust.test/xfail_compile/issue-407.rs @@ -0,0 +1,5 @@ +// { dg-excess-errors "failed to parse" } +fn test() { + let mut a = 1; + a + = 1; // { dg-error "found unexpected token ‘=’ in null denotation" +} |