aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2009-10-02 20:03:16 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2009-10-02 20:03:16 +0000
commit1aa8b1dd138a0b4aec3bc5747b7298475335e4d7 (patch)
tree6c00917bd9a69d7134985539e11695ed15c7ec5b /gcc/ada/gcc-interface/decl.c
parent9e51149de67a1f3cb79bf03c39b4fbeeb0718d89 (diff)
downloadgcc-1aa8b1dd138a0b4aec3bc5747b7298475335e4d7.zip
gcc-1aa8b1dd138a0b4aec3bc5747b7298475335e4d7.tar.gz
gcc-1aa8b1dd138a0b4aec3bc5747b7298475335e4d7.tar.bz2
decl.c (gnat_to_gnu_component_type): Force at least unit size for the component size of an array with aliased components.
* gcc-interface/decl.c (gnat_to_gnu_component_type): Force at least unit size for the component size of an array with aliased components. (maybe_pad_type): Do not warn for MAX_EXPR. From-SVN: r152417
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 3fb7c80..22ee89e 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -4990,6 +4990,17 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition,
Is_Bit_Packed_Array (gnat_array) ? TYPE_DECL : VAR_DECL,
true, Has_Component_Size_Clause (gnat_array));
+ /* If the array has aliased components and the component size can be zero,
+ force at least unit size to ensure that the components have distinct
+ addresses. */
+ if (!gnu_comp_size
+ && Has_Aliased_Components (gnat_array)
+ && (integer_zerop (TYPE_SIZE (gnu_type))
+ || (TREE_CODE (gnu_type) == ARRAY_TYPE
+ && !TREE_CONSTANT (TYPE_SIZE (gnu_type)))))
+ gnu_comp_size
+ = size_binop (MAX_EXPR, TYPE_SIZE (gnu_type), bitsize_unit_node);
+
/* If the component type is a RECORD_TYPE that has a self-referential size,
then use the maximum size for the component size. */
if (!gnu_comp_size
@@ -6210,6 +6221,7 @@ maybe_pad_type (tree type, tree size, unsigned int align,
if (Present (gnat_entity)
&& size
+ && TREE_CODE (size) != MAX_EXPR
&& !operand_equal_p (size, orig_size, 0)
&& !(TREE_CODE (size) == INTEGER_CST
&& TREE_CODE (orig_size) == INTEGER_CST