From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id BF3CF385782E for ; Mon, 15 Mar 2021 14:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF3CF385782E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 80150117EA6; Mon, 15 Mar 2021 10:31:44 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id CWc7mTJQu7eO; Mon, 15 Mar 2021 10:31:44 -0400 (EDT) Received: from murgatroyd.Home (71-211-137-228.hlrn.qwest.net [71.211.137.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 3D7EA117E06; Mon, 15 Mar 2021 10:31:44 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Fix unary + in Ada Date: Mon, 15 Mar 2021 08:31:42 -0600 Message-Id: <20210315143142.3392783-1-tromey@adacore.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Mar 2021 14:31:45 -0000 My previous Ada patches introduced a bug that I found after checkin. I had incorrectly implemented unary +. There was a test for the overloaded case, but no test for the ordinary case. This patch adds the tests and fixes the bug. Tested on x86-64 Fedora 32. gdb/ChangeLog 2021-03-15 Tom Tromey * ada-exp.y (simple_exp): Always push a result for unary '+'. gdb/testsuite/ChangeLog 2021-03-15 Tom Tromey * gdb.ada/fixed_points.exp: Add tests of unary + and -. --- gdb/ChangeLog | 4 ++++ gdb/ada-exp.y | 8 +++++--- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.ada/fixed_points.exp | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index e8ffb8e1040..146b1acbe14 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -589,12 +589,14 @@ simple_exp : '+' simple_exp %prec UNARY operation_up arg = ada_pop (); operation_up empty; - /* We only need to handle the overloading - case here, not anything else. */ + /* If an overloaded operator was found, use + it. Otherwise, unary + has no effect and + the argument can be pushed instead. */ operation_up call = maybe_overload (UNOP_PLUS, arg, empty); if (call != nullptr) - pstate->push (std::move (call)); + arg = std::move (call); + pstate->push (std::move (arg)); } ; diff --git a/gdb/testsuite/gdb.ada/fixed_points.exp b/gdb/testsuite/gdb.ada/fixed_points.exp index 7267c3181ed..69565e77490 100644 --- a/gdb/testsuite/gdb.ada/fixed_points.exp +++ b/gdb/testsuite/gdb.ada/fixed_points.exp @@ -76,6 +76,11 @@ foreach_with_prefix scenario {all minimal} { gdb_test "print fp2_var - 0" \ " = -0.01" + gdb_test "print + fp2_var" \ + " = -0.01" + gdb_test "print - fp2_var" \ + " = 0.01" + set fp4 "= 2e-07" gdb_test "print fp4_var" $fp4 gdb_test "print fp4_var * 1" $fp4 -- 2.26.2