public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] Fix parsing grammer of grouped expressions as the block tail expression
Date: Tue, 19 Jul 2022 21:57:47 +0000 (GMT)	[thread overview]
Message-ID: <20220719215747.A8EF53858D1E@sourceware.org> (raw)

https://gcc.gnu.org/g:fb1b2a6bf5eed9dd9405dca9b9c895f48509875e

commit fb1b2a6bf5eed9dd9405dca9b9c895f48509875e
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Tue Jul 19 10:49:37 2022 +0100

    Fix parsing grammer of grouped expressions as the block tail expression
    
    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

Diff:
---
 gcc/rust/parse/rust-parse-impl.h         |  6 ------
 gcc/testsuite/rust/compile/issue-1393.rs | 13 +++++++++++++
 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 227564cb65a..d925aca05e9 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 00000000000..e09f01b62e5
--- /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()
+}


                 reply	other threads:[~2022-07-19 21:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220719215747.A8EF53858D1E@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).