aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-05-15 23:15:38 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-07 05:27:00 -0400
commite1b0956a8e1f5609266cbe064b345bbb37b1e7e2 (patch)
tree7b97c7c9c4d38ca38fd659883763ae10fa128d57
parente997d94b298c5ea753b613c38518a2c72bdf44af (diff)
downloadgcc-e1b0956a8e1f5609266cbe064b345bbb37b1e7e2.zip
gcc-e1b0956a8e1f5609266cbe064b345bbb37b1e7e2.tar.gz
gcc-e1b0956a8e1f5609266cbe064b345bbb37b1e7e2.tar.bz2
[Ada] Small adjustment in the handling of alignment for arrays
gcc/ada/ * freeze.adb (Freeze_Array_Type): Use Ctyp more consistently. Move code setting the alignment in the non-packed case to... * layout.adb (Layout_Type): ...here.
-rw-r--r--gcc/ada/freeze.adb25
-rw-r--r--gcc/ada/layout.adb16
2 files changed, 21 insertions, 20 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index fd76e7b..7c6fac1 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -2573,13 +2573,13 @@ package body Freeze is
-- Propagate flags for component type
- if Is_Controlled (Component_Type (Arr))
+ if Is_Controlled (Ctyp)
or else Has_Controlled_Component (Ctyp)
then
Set_Has_Controlled_Component (Arr);
end if;
- if Has_Unchecked_Union (Component_Type (Arr)) then
+ if Has_Unchecked_Union (Ctyp) then
Set_Has_Unchecked_Union (Arr);
end if;
@@ -2590,7 +2590,7 @@ package body Freeze is
-- that the procedure can be used to check the array type
-- invariants if any.
- if Has_Invariants (Component_Type (Arr))
+ if Has_Invariants (Ctyp)
and then not GNATprove_Mode
then
Set_Has_Own_Invariants (Arr);
@@ -2902,8 +2902,8 @@ package body Freeze is
-- If the Esize of the component is known and equal to
-- the component size then even packing is not needed.
- if Known_Static_Esize (Component_Type (Arr))
- and then Esize (Component_Type (Arr)) = Csiz
+ if Known_Static_Esize (Ctyp)
+ and then Esize (Ctyp) = Csiz
then
-- Here the array was requested to be packed, but
-- the packing request had no effect whatsoever,
@@ -3157,21 +3157,6 @@ package body Freeze is
<<Skip_Packed>>
- -- For non-packed arrays set the alignment of the array to the
- -- alignment of the component type if it is unknown. Skip this
- -- in atomic/VFA case (atomic/VFA arrays may need larger alignments).
-
- if not Is_Packed (Arr)
- and then Unknown_Alignment (Arr)
- and then Known_Alignment (Ctyp)
- and then Known_Static_Component_Size (Arr)
- and then Known_Static_Esize (Ctyp)
- and then Esize (Ctyp) = Component_Size (Arr)
- and then not Is_Atomic_Or_VFA (Arr)
- then
- Set_Alignment (Arr, Alignment (Component_Type (Arr)));
- end if;
-
-- A Ghost type cannot have a component of protected or task type
-- (SPARK RM 6.9(19)).
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index 33728c0..73812f6 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -467,6 +467,22 @@ package body Layout is
end if;
end;
end if;
+
+ -- For non-packed arrays set the alignment of the array to the
+ -- alignment of the component type if it is unknown. Skip this
+ -- in atomic/VFA case since a larger alignment may be needed.
+
+ if Is_Array_Type (E)
+ and then not Is_Packed (E)
+ and then Unknown_Alignment (E)
+ and then Known_Alignment (Component_Type (E))
+ and then Known_Static_Component_Size (E)
+ and then Known_Static_Esize (Component_Type (E))
+ and then Component_Size (E) = Esize (Component_Type (E))
+ and then not Is_Atomic_Or_VFA (E)
+ then
+ Set_Alignment (E, Alignment (Component_Type (E)));
+ end if;
end if;
-- Even if the backend performs the layout, we still do a little in