aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-07-19 10:32:55 +0000
committerGitHub <noreply@github.com>2022-07-19 10:32:55 +0000
commit1b5676645a52f46de0011b9434f76c249fbb8d81 (patch)
treeded83a957b116bbc40c46367f5e0d7e001fa3bd2
parent6622ae2cd0a6b69b84a33f61ae7707c02caa88b9 (diff)
parentfb1b2a6bf5eed9dd9405dca9b9c895f48509875e (diff)
downloadgcc-1b5676645a52f46de0011b9434f76c249fbb8d81.zip
gcc-1b5676645a52f46de0011b9434f76c249fbb8d81.tar.gz
gcc-1b5676645a52f46de0011b9434f76c249fbb8d81.tar.bz2
Merge #1394
1394: Fix parsing grammer of grouped expressions as the block tail expression r=philberty a=philberty When we want to compile a grouped expression we had a check for the LEFT_PAREN during the parse_expr_without_block but this can't be handled here since in this paticular example the grouped expressions is simply the lhs of the bit shift expression. This is already handled as part of parse_expr so we can simply remove the rule here and rely on parse_expr handling this. Fixes #1393 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
-rw-r--r--gcc/rust/parse/rust-parse-impl.h6
-rw-r--r--gcc/testsuite/rust/compile/issue-1393.rs13
2 files changed, 13 insertions, 6 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 227564c..d925aca 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -7276,12 +7276,6 @@ Parser<ManagedTokenSource>::parse_expr_without_block (
case LEFT_SQUARE:
// array expr (creation, not index)
return parse_array_expr (std::move (outer_attrs));
- case LEFT_PAREN:
- /* either grouped expr or tuple expr - depends on whether there is a
- * comma
- * inside the parentheses - if so, tuple expr, otherwise, grouped expr.
- */
- return parse_grouped_or_tuple_expr (std::move (outer_attrs));
default: {
/* HACK: piggyback on pratt parsed expr and abuse polymorphism to
* essentially downcast */
diff --git a/gcc/testsuite/rust/compile/issue-1393.rs b/gcc/testsuite/rust/compile/issue-1393.rs
new file mode 100644
index 0000000..e09f01b
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-1393.rs
@@ -0,0 +1,13 @@
+fn tst() {
+ let a = 123;
+ let b = 0;
+ let _c = if b == 0 {
+ (a & 0x7fffff) << 1
+ } else {
+ (a & 0x7fffff) | 0x800000
+ };
+}
+
+fn main() {
+ tst()
+}