[Ada] Remove new strict-alignment check added by AI12-0001

Message ID 20191216103826.GA39463@adacore.com
State New
Headers show
  • [Ada] Remove new strict-alignment check added by AI12-0001
Related show

Commit Message

Pierre-Marie de Rodat Dec. 16, 2019, 10:38 a.m.
This removes the check on aliased components recently added to the
Check_Strict_Alignment procedure as part of the implementation of
AI12-0001 because it causes a build failure for Florist on 32-bit
platforms and might also affect other legacy codebases.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-12-16  Eric Botcazou  <ebotcazou@adacore.com>


	* freeze.adb (Check_Strict_Alignment): Remove new check on
	Has_Aliased_Components for array types.


--- gcc/ada/freeze.adb
+++ gcc/ada/freeze.adb
@@ -1614,24 +1614,22 @@  package body Freeze is
          Set_Strict_Alignment (E);
       elsif Is_Array_Type (E) then
-         if Has_Aliased_Components (E)
-           or else Strict_Alignment (Component_Type (E))
-         then
-            Set_Strict_Alignment (E);
-         end if;
+         Set_Strict_Alignment (E, Strict_Alignment (Component_Type (E)));
-      elsif Is_Record_Type (E) then
-         --  ??? If the type has convention C_Pass_By_Copy, we consider
-         --  that it may be packed even if it contains aliased parts.
-         --  Such types are very unlikely to be misaligned in practice
-         --  and this makes the compiler accept dubious representation
-         --  clauses used in Florist on types containing arrays with
-         --  aliased components.
-         if C_Pass_By_Copy (E) then
-            return;
-         end if;
+         --  ??? 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.
+      elsif Is_Record_Type (E) then
          Comp := First_Component (E);
          while Present (Comp) loop
             if not Is_Type (Comp)