public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix operator precedence bug in Rust parser Date: Tue, 6 Dec 2022 14:43:02 +0000 (GMT) [thread overview] Message-ID: <20221206144302.02C083846999@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e03698c1227bc18835cc2e4a9146a8369635e119 commit e03698c1227bc18835cc2e4a9146a8369635e119 Author: Tom Tromey <tromey@adacore.com> Date: Tue Dec 6 07:41:52 2022 -0700 Fix operator precedence bug in Rust parser PR rust/29859 points out an operator precedence bug in the Rust parser. This patch fixes it and adds a regression test. Diff: --- gdb/rust-parse.c | 2 +- gdb/testsuite/gdb.rust/simple.exp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index f5eb63ec1e3..337927219d5 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -1398,7 +1398,7 @@ rust_parser::parse_binop (bool required) break; } - while (precedence < operator_stack.back ().precedence + while (precedence <= operator_stack.back ().precedence && operator_stack.size () > 1) { rustop_item rhs = std::move (operator_stack.back ()); diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index 252c47baac5..3a010f30ea6 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -412,3 +412,7 @@ if {[lindex $v 0] >= 8} { gdb_test "python print(gdb.lookup_type('simple::MoreComplicated').dynamic)" \ "True" } + +# The new parser introduced an operator precedence bug. +gdb_test "print 5 * 7 / 5" " = 7" +gdb_test "print 4 - 3 - 1" " = 0"
reply other threads:[~2022-12-06 14:43 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=20221206144302.02C083846999@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.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: linkBe 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).