]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Add more initialization of Stored_Constraint
authorRichard Kenner <kenner@adacore.com>
Sun, 14 Feb 2021 13:02:19 +0000 (08:02 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 15 Jun 2021 10:19:11 +0000 (06:19 -0400)
gcc/ada/

* sem_ch3.adb (Array_Type_Declaration, Build_Derived_Type):
Reinitialize Stored_Constraint when needed.
(Set_Modular_Size): Likewise.
* atree.adb: (Check_Vanishing_Fields): Add node id to debugging
information.

gcc/ada/atree.adb
gcc/ada/sem_ch3.adb

index 541655c466fd178347e98879f0fe491b012ac760..d0b06bbce5e614d790e885ad9b6d70351e0d497e 100644 (file)
@@ -772,7 +772,8 @@ package body Atree is
                   Write_Str (New_Kind'Img);
                   Write_Str (" Nonzero field ");
                   Write_Str (F'Img);
-                  Write_Str (" is vanishing");
+                  Write_Str (" is vanishing for node ");
+                  Write_Int (Nat (Old_N));
                   Write_Eol;
 
                   raise Program_Error;
@@ -845,7 +846,8 @@ package body Atree is
                   Write_Str (New_Kind'Img);
                   Write_Str (" Nonzero field ");
                   Write_Str (F'Img);
-                  Write_Str (" is vanishing ");
+                  Write_Str (" is vanishing for node ");
+                  Write_Int (Nat (Old_N));
                   Write_Eol;
 
                   if New_Kind = E_Void or else Old_Kind = E_Void then
index f67c40ed466e79e043b13bb5ce5454ef1fa61cd2..1eac9057c418fc1c6f2817c7958b8e8e27c8fbd9 100644 (file)
@@ -6191,6 +6191,12 @@ package body Sem_Ch3 is
 
       if Nkind (Def) = N_Constrained_Array_Definition then
 
+         if Ekind (T) in Incomplete_Or_Private_Kind then
+            Reinit_Field_To_Zero (T, Stored_Constraint);
+         else
+            pragma Assert (Ekind (T) = E_Void);
+         end if;
+
          --  Establish Implicit_Base as unconstrained base type
 
          Implicit_Base := Create_Itype (E_Array_Type, P, Related_Id, 'B');
@@ -9749,6 +9755,12 @@ package body Sem_Ch3 is
    begin
       --  Set common attributes
 
+      if Ekind (Derived_Type) in Incomplete_Or_Private_Kind
+        and then Ekind (Parent_Base) in Modular_Integer_Kind | Array_Kind
+      then
+         Reinit_Field_To_Zero (Derived_Type, Stored_Constraint);
+      end if;
+
       Set_Scope                  (Derived_Type, Current_Scope);
       Set_Etype                  (Derived_Type,        Parent_Base);
       Mutate_Ekind               (Derived_Type, Ekind (Parent_Base));
@@ -19618,6 +19630,11 @@ package body Sem_Ch3 is
       --  Proceed with analysis of mod expression
 
       Analyze_And_Resolve (Mod_Expr, Any_Integer);
+
+      if Ekind (T) in Incomplete_Or_Private_Kind then
+         Reinit_Field_To_Zero (T, Stored_Constraint);
+      end if;
+
       Set_Etype (T, T);
       Mutate_Ekind (T, E_Modular_Integer_Type);
       Init_Alignment (T);