aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/layout.adb
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2017-10-14 17:07:35 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2017-10-14 17:07:35 +0000
commit92b751fdc698c7b2040f986aaa125e4163003a2d (patch)
tree9877668163ec28526d8a074dc94e2f8c2e60e565 /gcc/ada/layout.adb
parent2e60feb59198791c0a3b58838af26e6e5cd32677 (diff)
downloadgcc-92b751fdc698c7b2040f986aaa125e4163003a2d.zip
gcc-92b751fdc698c7b2040f986aaa125e4163003a2d.tar.gz
gcc-92b751fdc698c7b2040f986aaa125e4163003a2d.tar.bz2
[multiple changes]
2017-10-14 Eric Botcazou <ebotcazou@adacore.com> * layout.ads (Set_Elem_Alignment): Add Align parameter defaulted to 0. * layout.adb (Set_Elem_Alignment): Likewise. Use M name as maximum alignment for consistency. If Align is non-zero, use the minimum of Align and M for the alignment. * cstand.adb (Build_Float_Type): Use Set_Elem_Alignment instead of setting the alignment directly. 2017-10-14 Ed Schonberg <schonberg@adacore.com> * sem_prag.adb (Analyze_Pragma, case Check): Defer evaluation of the optional string in an Assert pragma until the expansion of the pragma has rewritten it as a conditional statement, so that the string argument is only evaluaed if the assertion fails. This is mandated by RM 11.4.2. 2017-10-14 Hristian Kirtchev <kirtchev@adacore.com> * debug.adb: Switch -gnatd.v and associated flag are now used to enforce the SPARK rules for elaboration in SPARK code. * sem_elab.adb: Describe switch -gnatd.v. (Process_Call): Verify the SPARK rules only when -gnatd.v is in effect. (Process_Instantiation): Verify the SPARK rules only when -gnatd.v is in effect. (Process_Variable_Assignment): Clarify why variable assignments are processed reglardless of whether -gnatd.v is in effect. * doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Update the sections on elaboration code and compilation switches. * gnat_ugn.texi: Regenerate. 2017-10-14 Gary Dismukes <dismukes@adacore.com> * exp_util.adb, freeze.adb, sem_aggr.adb, sem_util.ads, sem_util.adb, sem_warn.adb: Minor reformattings. From-SVN: r253757
Diffstat (limited to 'gcc/ada/layout.adb')
-rw-r--r--gcc/ada/layout.adb32
1 files changed, 19 insertions, 13 deletions
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index 34c5b5d..52e8452 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -843,7 +843,7 @@ package body Layout is
-- Set_Elem_Alignment --
------------------------
- procedure Set_Elem_Alignment (E : Entity_Id) is
+ procedure Set_Elem_Alignment (E : Entity_Id; Align : Nat := 0) is
begin
-- Do not set alignment for packed array types, this is handled in the
-- backend.
@@ -869,15 +869,12 @@ package body Layout is
return;
end if;
- -- Here we calculate the alignment as the largest power of two multiple
- -- of System.Storage_Unit that does not exceed either the object size of
- -- the type, or the maximum allowed alignment.
+ -- We attempt to set the alignment in all the other cases
declare
S : Int;
A : Nat;
-
- Max_Alignment : Nat;
+ M : Nat;
begin
-- The given Esize may be larger that int'last because of a previous
@@ -908,7 +905,7 @@ package body Layout is
and then S = 8
and then Is_Floating_Point_Type (E)
then
- Max_Alignment := Ttypes.Target_Double_Float_Alignment;
+ M := Ttypes.Target_Double_Float_Alignment;
-- If the default alignment of "double" or larger scalar types is
-- specifically capped, enforce the cap.
@@ -917,18 +914,27 @@ package body Layout is
and then S >= 8
and then Is_Scalar_Type (E)
then
- Max_Alignment := Ttypes.Target_Double_Scalar_Alignment;
+ M := Ttypes.Target_Double_Scalar_Alignment;
-- Otherwise enforce the overall alignment cap
else
- Max_Alignment := Ttypes.Maximum_Alignment;
+ M := Ttypes.Maximum_Alignment;
end if;
- A := 1;
- while 2 * A <= Max_Alignment and then 2 * A <= S loop
- A := 2 * A;
- end loop;
+ -- We calculate the alignment as the largest power-of-two multiple
+ -- of System.Storage_Unit that does not exceed the object size of
+ -- the type and the maximum allowed alignment, if none was specified.
+ -- Otherwise we only cap it to the maximum allowed alignment.
+
+ if Align = 0 then
+ A := 1;
+ while 2 * A <= S and then 2 * A <= M loop
+ A := 2 * A;
+ end loop;
+ else
+ A := Nat'Min (Align, M);
+ end if;
-- If alignment is currently not set, then we can safely set it to
-- this new calculated value.