]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Compiler crash on early alignment clause
authorBob Duff <duff@adacore.com>
Wed, 18 Oct 2023 13:54:06 +0000 (09:54 -0400)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 7 Nov 2023 09:15:05 +0000 (10:15 +0100)
This patch fixes a bug: if "for T'Alignment use..." is followed
by "for T use (<enum rep>);" the compiler crashes. A workaround is
to move the alignment clause after the enumeration rep clause.

gcc/ada/

* sem_ch13.ads (Set_Enum_Esize): Do not set alignment.
* sem_ch13.adb (Set_Enum_Esize): Do not set alignment. Archaeology
seems to show that this line of code dates from when "Alignment =
0" meant "the Alignment is not known at compile time" and "the
Alignment is not yet known at compile time" as well as "the
Alignment is zero". In any case, it seems to be unnecessary, and
in this case harmful, because gigi would crash. Alignment_Clause
is set (because there is one), so gigi would query the Alignment,
but Alignment was destroyed.

gcc/ada/sem_ch13.adb
gcc/ada/sem_ch13.ads

index 5747ee9c53911991c5fa0d2032ea8e9dfbba7504..302fab74757ab1b3ec7f68fd09eddfc8cfd40c21 100644 (file)
@@ -17381,8 +17381,6 @@ package body Sem_Ch13 is
       Sz : Unat;
 
    begin
-      Reinit_Alignment (T);
-
       --  Find the minimum standard size (8,16,32,64,128) that fits
 
       Lo := Enumeration_Rep (Entity (Type_Low_Bound (T)));
index 1386096535eed24b04eba9890d316582985f1627..555d302fb1045809f0c830a4615cb3a41cbb5d8c 100644 (file)
@@ -79,8 +79,7 @@ package Sem_Ch13 is
    procedure Set_Enum_Esize (T : Entity_Id);
    --  This routine sets the Esize field for an enumeration type T, based
    --  on the current representation information available for T. Note that
-   --  the setting of the RM_Size field is not affected. This routine also
-   --  initializes the alignment field to zero.
+   --  the setting of the RM_Size field is not affected.
 
    Unknown_Minimum_Size : constant Nonzero_Int := -1;