Allow re-assigning to convenience variables
authorTom Tromey <tromey@adacore.com>
Wed, 5 Jun 2019 16:53:16 +0000 (10:53 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 14 Jun 2019 14:06:16 +0000 (08:06 -0600)
In Ada mode, re-assigning an array of a different size to a
convenience variable will cause an error:

    (gdb) set lang ada
    (gdb) set $v := "abc"
    (gdb) set $v := "abcd"
    cannot assign arrays of different length

However, this does not really make sense -- instead, it should always
be possible to overwrite a convenience variable.

This patch fixes this bug.

This was reviewed off-list by Joel.  I'm checking it in.

gdb/ChangeLog
2019-06-14  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (ada_evaluate_subexp) <case BINOP_ASSIGN>: Always
allow assignment to an internalvar.

gdb/testsuite/ChangeLog
2019-06-14  Tom Tromey  <tromey@adacore.com>

* gdb.ada/set_wstr.exp: Add reassignment test.

gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/set_wstr.exp

index 9fbfcfa9b7203b41b183f8114317d4f62b3a5381..ee3377c56b29c8f80e7b3882b5d2766e2e3fa444 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-14  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (ada_evaluate_subexp) <case BINOP_ASSIGN>: Always
+       allow assignment to an internalvar.
+
 2019-06-14  Tom Tromey  <tromey@adacore.com>
 
        * ada-lex.l: Allow "_" in attribute names.
index 1f0ada35902422a61245e688cddd6a20758b0f03..1b5f18316fadbfc6074615e02364f5f7761cf756 100644 (file)
@@ -10486,7 +10486,11 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       arg2 = evaluate_subexp (type, exp, pos, noside);
       if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
         return arg1;
-      if (ada_is_fixed_point_type (value_type (arg1)))
+      if (VALUE_LVAL (arg1) == lval_internalvar)
+       {
+         /* Nothing.  */
+       }
+      else if (ada_is_fixed_point_type (value_type (arg1)))
         arg2 = cast_to_fixed (value_type (arg1), arg2);
       else if (ada_is_fixed_point_type (value_type (arg2)))
         error
index 9bfd570f48fb42dd6d1e1c423575b00f7f6af6b2..82194862423f4409b9d235df663f2a26b8b5813b 100644 (file)
@@ -1,3 +1,7 @@
+2019-06-14  Tom Tromey  <tromey@adacore.com>
+
+       * gdb.ada/set_wstr.exp: Add reassignment test.
+
 2019-06-14  Tom Tromey  <tromey@adacore.com>
 
        * gdb.ada/formatted_ref.exp (test_p_x_addr): Check
index 0c5c42c17dceb0da63cfec5aa94e460a9ef96c55..ac7098515daa1f248634d653181af7252db6e77c 100644 (file)
@@ -72,3 +72,8 @@ gdb_test "print rws" \
 
 gdb_test "set variable www := \"1#2#3#4#5#\"" \
          "cannot assign arrays of different length"
+
+# However, reassigning an array of a different length should work when
+# the LHS is a convenience variable.
+gdb_test_no_output "set variable \$str := \"1234\""
+gdb_test_no_output "set variable \$str := \"12345\""
This page took 0.039905 seconds and 4 git commands to generate.