diff mbox series

[Ada] Fix error on too large size clause for bit-packed array

Message ID 20220110094132.GA586014@adacore.com
State New
Headers show
Series [Ada] Fix error on too large size clause for bit-packed array | expand

Commit Message

Pierre-Marie de Rodat Jan. 10, 2022, 9:41 a.m. UTC
The compiler should give again a warning instead of an error, which comes
from an improper Esize set on the bit-packed array type by Layout_Type.

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

gcc/ada/

	* exp_pakd.adb (Install_PAT): Do not reset the alignment here.
	* layout.adb (Layout_Type): Call Adjust_Esize_Alignment after having
	copied the RM_Size onto the Esize when the latter is too small.
diff mbox series

Patch

diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb
--- a/gcc/ada/exp_pakd.adb
+++ b/gcc/ada/exp_pakd.adb
@@ -577,7 +577,6 @@  package body Exp_Pakd is
 
          --  Set remaining fields of packed array type
 
-         Reinit_Alignment              (PAT);
          Set_Parent                    (PAT, Empty);
          Set_Associated_Node_For_Itype (PAT, Typ);
          Set_Original_Array_Type       (PAT, Typ);


diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -616,7 +616,7 @@  package body Layout is
                Size : constant Uint := RM_Size (E);
 
             begin
-               Set_Esize (E, RM_Size (E));
+               Set_Esize (E, Size);
 
                --  For scalar types, increase Object_Size to power of 2, but
                --  not less than a storage unit in any case (i.e., normally
@@ -641,6 +641,11 @@  package body Layout is
                   loop
                      Set_Alignment (E, 2 * Alignment (E));
                   end loop;
+
+               --  For the other types, apply standard adjustments
+
+               else
+                  Adjust_Esize_Alignment (E);
                end if;
             end;
          end if;