diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2018-12-11 11:11:31 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-12-11 11:11:31 +0000 |
commit | 6186a6ef3c5d54134e68a0f54ad736e405876269 (patch) | |
tree | b70f11386b52bb051ba0a8178d21ea4101368992 /gcc/ada/gcc-interface/decl.c | |
parent | af3ded0832bd13e8f00fc62d96a367635398d1d6 (diff) | |
download | gcc-6186a6ef3c5d54134e68a0f54ad736e405876269.zip gcc-6186a6ef3c5d54134e68a0f54ad736e405876269.tar.gz gcc-6186a6ef3c5d54134e68a0f54ad736e405876269.tar.bz2 |
[Ada] Fix elaboration of record with 1-element dynamic array
2018-12-11 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* einfo.ads (Is_Bit_Packed_Array): Fix values of component size.
(Is_Packed): Likewise.
* gcc-interface/utils.c (convert): Do not extract the value of a
justified modular type if the destination type is a regular
array.
* gcc-interface/decl.c (gnat_to_gnu_component_type): Pass
TYPE_DECL to validate_size wherever the array has packed
components.
From-SVN: r267005
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 758f2c3..eaa1a52 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -5051,6 +5051,7 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, { const Entity_Id gnat_type = Component_Type (gnat_array); tree gnu_type = gnat_to_gnu_type (gnat_type); + bool has_packed_components = Is_Bit_Packed_Array (gnat_array); tree gnu_comp_size; unsigned int max_align; @@ -5063,20 +5064,23 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, else max_align = 0; - /* Try to get a smaller form of the component if needed. */ + /* Try to get a packable form of the component if needed. */ if ((Is_Packed (gnat_array) || Has_Component_Size_Clause (gnat_array)) - && !Is_Bit_Packed_Array (gnat_array) && !Has_Aliased_Components (gnat_array) && !Strict_Alignment (gnat_type) + && !has_packed_components && RECORD_OR_UNION_TYPE_P (gnu_type) && !TYPE_FAT_POINTER_P (gnu_type) && tree_fits_uhwi_p (TYPE_SIZE (gnu_type))) - gnu_type = make_packable_type (gnu_type, false, max_align); + { + gnu_type = make_packable_type (gnu_type, false, max_align); + has_packed_components = true; + } /* Get and validate any specified Component_Size. */ gnu_comp_size = validate_size (Component_Size (gnat_array), gnu_type, gnat_array, - Is_Bit_Packed_Array (gnat_array) ? TYPE_DECL : VAR_DECL, + has_packed_components ? TYPE_DECL : VAR_DECL, true, Has_Component_Size_Clause (gnat_array)); /* If the component type is a RECORD_TYPE that has a self-referential size, |