]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix crash on reference to aliased object of packed array type with -g
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 28 Jul 2025 20:16:08 +0000 (22:16 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 11 Sep 2025 09:10:50 +0000 (11:10 +0200)
This happens when the object is declared in another compilation unit.

gcc/ada/ChangeLog:

* gcc-interface/misc.cc (gnat_get_array_descr_info): In the record
type case, bail out if the original array type cannot be retrieved.

gcc/ada/gcc-interface/misc.cc

index 7711f8b0f82ab47f7f67e124c28cca2fdb8c03b9..a79b87e3bdb294bf8e0398213a02e87b981e98b8 100644 (file)
@@ -837,6 +837,8 @@ gnat_get_array_descr_info (const_tree const_type,
       if (TYPE_IMPL_PACKED_ARRAY_P (array_type)
           && TYPE_ORIGINAL_PACKED_ARRAY (array_type))
         array_type = TYPE_ORIGINAL_PACKED_ARRAY (array_type);
+      if (TREE_CODE (array_type) != ARRAY_TYPE)
+       return false;
 
       /* Shift back the address to get the address of the template.  */
       tree shift_amount