aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-01-07 06:58:19 -0700
committerTom Tromey <tromey@adacore.com>2021-01-07 06:58:19 -0700
commitd4813f104685d3b36ab0c36a928264f99f5d3f17 (patch)
tree87b4572f002a155102ce0a11908f6d4b3ac52473
parent17d60030ae57fb53f5977fa6928d7d5006f42881 (diff)
downloadfsf-binutils-gdb-d4813f104685d3b36ab0c36a928264f99f5d3f17.zip
fsf-binutils-gdb-d4813f104685d3b36ab0c36a928264f99f5d3f17.tar.gz
fsf-binutils-gdb-d4813f104685d3b36ab0c36a928264f99f5d3f17.tar.bz2
Fix regression in Ada aggregate assignment
A recent upstream patch of mine caused a regression in aggregate assignment. The bug was that add_component_interval didn't properly update the array contents in one resize case. I found furthermore that there was no test case that would provoke this failure. This patch fixes the bug and introduces a test. gdb/ChangeLog 2021-01-07 Tom Tromey <tromey@adacore.com> * ada-lang.c (add_component_interval): Start loop using vector's updated size. gdb/testsuite/ChangeLog 2021-01-07 Tom Tromey <tromey@adacore.com> * gdb.ada/assign_arr.exp: Add 'others' test.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-lang.c2
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.ada/assign_arr.exp3
4 files changed, 13 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 44dfabf..dd8c01b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2021-01-07 Tom Tromey <tromey@adacore.com>
+
+ * ada-lang.c (add_component_interval): Start loop using vector's
+ updated size.
+
2021-01-06 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_evaluate_subexp) <BINOP_ADD, BINOP_SUB>:
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3bc7bdd..4751b6e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9755,7 +9755,7 @@ add_component_interval (LONGEST low, LONGEST high,
}
indices.resize (indices.size () + 2);
- for (j = size - 1; j >= i + 2; j -= 1)
+ for (j = indices.size () - 1; j >= i + 2; j -= 1)
indices[j] = indices[j - 2];
indices[i] = low;
indices[i + 1] = high;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8d5a2ee..0f3ef7a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2021-01-07 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/assign_arr.exp: Add 'others' test.
+
2021-01-06 Tom Tromey <tromey@adacore.com>
* gdb.ada/fixed_points/pck.ads (Delta4): New constant.
diff --git a/gdb/testsuite/gdb.ada/assign_arr.exp b/gdb/testsuite/gdb.ada/assign_arr.exp
index 2c79371..ca894f0 100644
--- a/gdb/testsuite/gdb.ada/assign_arr.exp
+++ b/gdb/testsuite/gdb.ada/assign_arr.exp
@@ -30,3 +30,6 @@ runto "main_p324_051.adb:$bp_location"
gdb_test "print assign_arr_input.u2 :=(0.25,0.5,0.75)" \
" = \\(0\\.25, 0\\.5, 0\\.75\\)"
+
+gdb_test "print assign_arr_input.u2 :=(0.25, others => 0.125)" \
+ " = \\(0\\.25, 0\\.125, 0\\.125\\)"