]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix crash on aliased constant with packed array type and -g switch
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 12 Jan 2024 09:50:01 +0000 (10:50 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 21 May 2024 07:26:49 +0000 (09:26 +0200)
The problem is that we build a template whose array field is not an array
in the case of an aliased object with nominal unconstrained array subtype.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: For an
array allocated with its bounds, make sure to have an array type
to build the template.

gcc/ada/gcc-interface/decl.cc

index ca174bff009730df0a2444ec1d910679f170f83d..41d5c29a17c1409d8c062c82d3942a714807d5be 100644 (file)
@@ -939,6 +939,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
            && !type_annotate_only)
          {
            tree gnu_array = gnat_to_gnu_type (Base_Type (gnat_type));
+           /* Make sure to have an array type for the template.  */
+           if (TYPE_IS_PADDING_P (gnu_type))
+             gnu_type = TREE_TYPE (TYPE_FIELDS (gnu_type));
            gnu_type
              = build_unc_object_type_from_ptr (TREE_TYPE (gnu_array),
                                                gnu_type,