diff options
author | Tom Tromey <tromey@adacore.com> | 2021-03-15 08:20:24 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2021-03-15 08:20:24 -0600 |
commit | 6813ceb03f889f4ed0dd163866b6eaa42a097838 (patch) | |
tree | 312d1f2933bda27b6b1d5a1195d567687c3561d3 | |
parent | 3b5c4de0cf93667ffc98f112db7dcbea92292e32 (diff) | |
download | gdb-6813ceb03f889f4ed0dd163866b6eaa42a097838.zip gdb-6813ceb03f889f4ed0dd163866b6eaa42a097838.tar.gz gdb-6813ceb03f889f4ed0dd163866b6eaa42a097838.tar.bz2 |
Fix unary + in Ada
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 <tromey@adacore.com>
* ada-exp.y (simple_exp): Always push a result for unary '+'.
gdb/testsuite/ChangeLog
2021-03-15 Tom Tromey <tromey@adacore.com>
* gdb.ada/fixed_points.exp: Add tests of unary + and -.
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/ada-exp.y | 8 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/fixed_points.exp | 5 |
4 files changed, 18 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d7f237e..ff0cc2c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2021-03-15 Tom Tromey <tromey@adacore.com> + * ada-exp.y (simple_exp): Always push a result for unary '+'. + +2021-03-15 Tom Tromey <tromey@adacore.com> + * ada-lang.c (ada_unop_ind_operation::evaluate): Call ada_ensure_varsize_limit. diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index e8ffb8e..146b1ac 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/ChangeLog b/gdb/testsuite/ChangeLog index aa6cacb..6ed26d1 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2021-03-15 Tom Tromey <tromey@adacore.com> + * gdb.ada/fixed_points.exp: Add tests of unary + and -. + +2021-03-15 Tom Tromey <tromey@adacore.com> + * gdb.ada/varsize_limit.exp: Add new test. * gdb.ada/varsize_limit/vsizelim.adb: Update. diff --git a/gdb/testsuite/gdb.ada/fixed_points.exp b/gdb/testsuite/gdb.ada/fixed_points.exp index 7267c31..69565e7 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 |