diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-08-05 13:06:17 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-08-23 10:51:05 +0200 |
commit | 19c22fbea31ae421d5b09a9d0b4f91438310ac45 (patch) | |
tree | 2c9a24dfd6bc26e038e951c937958e3db1384a14 /gcc | |
parent | 87bdd17829e93bf98d8984d6a16ed25081af6c0d (diff) | |
download | gcc-19c22fbea31ae421d5b09a9d0b4f91438310ac45.zip gcc-19c22fbea31ae421d5b09a9d0b4f91438310ac45.tar.gz gcc-19c22fbea31ae421d5b09a9d0b4f91438310ac45.tar.bz2 |
ada: Fix crash on aliased variable with packed array type and -g switch
This comes from a loophole in gnat_get_array_descr_info for record types
containing a template, which represent an aliased array, when this array
type is bit-packed and implemented as a modular integer.
gcc/ada/
* gcc-interface/misc.cc (gnat_get_array_descr_info): Test the
BIT_PACKED_ARRAY_TYPE_P flag only once on the final debug type. In
the case of records containing a template, replay the entire
processing for the array type contained therein.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/gcc-interface/misc.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc index f77629c..13cb39e 100644 --- a/gcc/ada/gcc-interface/misc.cc +++ b/gcc/ada/gcc-interface/misc.cc @@ -784,7 +784,7 @@ gnat_get_array_descr_info (const_tree const_type, { tree type = const_cast<tree> (const_type); tree first_dimen, dimen; - bool is_bit_packed_array, is_array; + bool is_array; int i; /* Temporaries created in the first pass and used in the second one for thin @@ -797,12 +797,7 @@ gnat_get_array_descr_info (const_tree const_type, /* If we have an implementation type for a packed array, get the original array type. */ if (TYPE_IMPL_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type)) - { - is_bit_packed_array = BIT_PACKED_ARRAY_TYPE_P (type); - type = TYPE_ORIGINAL_PACKED_ARRAY (type); - } - else - is_bit_packed_array = false; + type = TYPE_ORIGINAL_PACKED_ARRAY (type); /* First pass: gather all information about this array except everything related to dimensions. */ @@ -833,6 +828,14 @@ gnat_get_array_descr_info (const_tree const_type, tree array_field = DECL_CHAIN (bounds_field); tree array_type = TREE_TYPE (array_field); + /* Replay the entire processing for array types. */ + if (TYPE_CAN_HAVE_DEBUG_TYPE_P (array_type) + && TYPE_DEBUG_TYPE (array_type)) + array_type = TYPE_DEBUG_TYPE (array_type); + if (TYPE_IMPL_PACKED_ARRAY_P (array_type) + && TYPE_ORIGINAL_PACKED_ARRAY (array_type)) + array_type = TYPE_ORIGINAL_PACKED_ARRAY (array_type); + /* Shift back the address to get the address of the template. */ tree shift_amount = fold_build1 (NEGATE_EXPR, sizetype, byte_position (array_field)); @@ -859,9 +862,7 @@ gnat_get_array_descr_info (const_tree const_type, /* If this array has fortran convention, it's arranged in column-major order, so our view here has reversed dimensions. */ const bool convention_fortran_p = TYPE_CONVENTION_FORTRAN_P (first_dimen); - - if (BIT_PACKED_ARRAY_TYPE_P (first_dimen)) - is_bit_packed_array = true; + const bool is_bit_packed_array = BIT_PACKED_ARRAY_TYPE_P (first_dimen); /* ??? For row major ordering, we probably want to emit nothing and instead specify it as the default in Dw_TAG_compile_unit. */ |