Call ada_ensure_varsize_limit in indirection
authorTom Tromey <tromey@adacore.com>
Mon, 15 Mar 2021 12:23:12 +0000 (06:23 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 15 Mar 2021 12:23:13 +0000 (06:23 -0600)
Internal testing revealed yet another Ada regression from the
expression rewrite.  In this case, indirection did not use the Ada
varsize limit.  The old code relied on the expression resolution
process to evaluate this subexpression with EVAL_AVOID_SIDE_EFFECTS in
order to get this error.  However, this isn't always done in the new
approach; so this patch introduces another call to
ada_ensure_varsize_limit in the appropriate spot.

As with the earlier patches, this path was not tested in-tree, so this
patch also updates a test.

gdb/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (ada_unop_ind_operation::evaluate): Call
ada_ensure_varsize_limit.

gdb/testsuite/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

* gdb.ada/varsize_limit.exp: Add new test.
* gdb.ada/varsize_limit/vsizelim.adb: Update.

gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/varsize_limit.exp
gdb/testsuite/gdb.ada/varsize_limit/vsizelim.adb

index a5580fde4d6e63d5067a7fd799b4a05ec639ac15..d7f237edc0787aa8af1b43c41c08b2d7f1b5f1c9 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-15  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (ada_unop_ind_operation::evaluate): Call
+       ada_ensure_varsize_limit.
+
 2021-03-15  Tom Tromey  <tromey@adacore.com>
 
        * ada-lang.c (numeric_type_p, integer_type_p): Return true for
index a74f5408484677d00c0ff7b645483aa58e75f1ed..1fc303a5c09ac15ee1ddc5cf911f29591f59ece5 100644 (file)
@@ -10480,6 +10480,11 @@ ada_unop_ind_operation::evaluate (struct type *expect_type,
                              (CORE_ADDR) value_as_address (arg1));
     }
 
+  struct type *target_type = (to_static_fixed_type
+                             (ada_aligned_type
+                              (ada_check_typedef (TYPE_TARGET_TYPE (type)))));
+  ada_ensure_varsize_limit (target_type);
+
   if (ada_is_array_descriptor_type (type))
     /* GDB allows dereferencing GNAT array descriptors.  */
     return ada_coerce_to_simple_array (arg1);
index 728405e960687cf56d74f0c04932c973411b3c90..aa6cacb6ada44e0f7a7260603f60b9e7c60df237 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-15  Tom Tromey  <tromey@adacore.com>
+
+       * gdb.ada/varsize_limit.exp: Add new test.
+       * gdb.ada/varsize_limit/vsizelim.adb: Update.
+
 2021-03-15  Tom Tromey  <tromey@adacore.com>
 
        * gdb.ada/operator_call/twovecs.ads: New file.
index eebb5d05def6d5dd0e3d9c0b532b3d8a884bc1a2..aca926a79ab92a84c6d3d9de271d77312675be6b 100644 (file)
@@ -37,4 +37,4 @@ gdb_test "print small" " = \"1234567890\""
 
 gdb_test "print larger" "object size is larger than varsize-limit.*"
 
-
+gdb_test "print name.all" "object size is larger than varsize-limit.*"
index 058994ce88a793f7680d20ad4e663bab4a7f7930..3b19e722eb23621f363772b48f5bd04c4f551054 100644 (file)
 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 with Pck; use Pck;
+with System;
+with Unchecked_Conversion;
+
 procedure VsizeLim is
    Small : String := Ident ("1234567890");
    Larger : String := Ident ("1234567890|1234567890|1234567890");
+
+   type String_Ptr is access all String;
+   type Big_String_Ptr is access all String (Positive);
+
+   function To_Ptr is
+     new Unchecked_Conversion (System.Address, Big_String_Ptr);
+
+   Name_Str : String_Ptr := new String'(Larger);
+   Name : Big_String_Ptr := To_Ptr (Name_Str.all'Address);
+
 begin
    Do_Nothing (Small'Address); -- STOP
    Do_Nothing (Larger'Address);
+   Do_Nothing (Name'Address);
 end VsizeLim;
This page took 0.052897 seconds and 4 git commands to generate.