-- d_i Ignore activations and calls to instances for elaboration
-- d_j Read JSON files and populate Repinfo tables (opposite of -gnatRjs)
-- d_k In CodePeer mode disable expansion of assertion checks
- -- d_l
+ -- d_l Disable strict alignment of array types with aliased component
-- d_m
-- d_n
-- d_o
-- enabled, expansion of assertion expressions is controlled by
-- pragma Assertion_Policy.
+ -- d_l The compiler does not enforce the strict alignment of array types
+ -- that are declared with an aliased component.
+
-- d_p The compiler ignores calls to subprograms which verify the run-time
-- semantics of invariants and postconditions in both the static and
-- dynamic elaboration models.
elsif Is_Array_Type (E) then
Set_Strict_Alignment (E, Strict_Alignment (Component_Type (E)));
- -- ??? AI12-001: Any component of a packed type that contains an
- -- aliased part must be aligned according to the alignment of its
- -- subtype (RM 13.2(7)). This means that the following test:
-
- -- if Has_Aliased_Components (E) then
- -- Set_Strict_Alignment (E);
- -- end if;
-
- -- should be implemented here. Unfortunately it would break Florist,
- -- which has the bad habit of overaligning all the types it declares
- -- on 32-bit platforms. Other legacy codebases could also be affected
- -- because this check has historically been missing in GNAT.
+ -- RM 13.2(7.1/4): Any component of a packed type that contains an
+ -- aliased part shall be aligned according to the alignment of its
+ -- subtype.
+
+ -- Unfortunately this breaks Florist, which has had the bad habit
+ -- of overaligning all the types it declares on 32-bit platforms,
+ -- so make an exception if the component size is the storage unit.
+
+ -- Other legacy codebases could also be affected because this was
+ -- historically not enforced, so -gnatd_l can be used to disable it.
+
+ if Has_Aliased_Components (E)
+ and then not (Known_Component_Size (E)
+ and then Component_Size (E) = System_Storage_Unit)
+ and then not Debug_Flag_Underscore_L
+ then
+ Set_Strict_Alignment (E);
+ end if;
elsif Is_Record_Type (E) then
Comp := First_Component (E);