diff mbox series

[Ada] Incorrect Reinit_Field_To_Zero calls for concurrent entities

Message ID 20210615102052.GA4213@adacore.com
State New
Headers show
Series [Ada] Incorrect Reinit_Field_To_Zero calls for concurrent entities | expand

Commit Message

Pierre-Marie de Rodat June 15, 2021, 10:20 a.m. UTC
This patch fixes some calls to Reinit_Field_To_Zero that were called for
too many or too few Ekinds. In particular, SPARK_Aux_Pragma_Inherited
does not exist in concurrent subtypes, causing crashes in Atree when the
pragmas at the start of the file are removed.

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

gcc/ada/

	* sem_ch3.adb (Make_Class_Wide_Type): Make sure all the calls to
	Reinit_Field_To_Zero are for the correct Ekinds.
diff mbox series

Patch

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -19239,14 +19239,17 @@  package body Sem_Ch3 is
          Reinit_Field_To_Zero (CW_Type, Private_Dependents);
 
       elsif Ekind (CW_Type) in Concurrent_Kind then
-         if Ekind (CW_Type) = E_Task_Type then
+         Reinit_Field_To_Zero (CW_Type, First_Private_Entity);
+         Reinit_Field_To_Zero (CW_Type, Scope_Depth_Value);
+
+         if Ekind (CW_Type) in Task_Kind then
             Reinit_Field_To_Zero (CW_Type, Is_Elaboration_Checks_OK_Id);
             Reinit_Field_To_Zero (CW_Type, Is_Elaboration_Warnings_OK_Id);
          end if;
 
-         Reinit_Field_To_Zero (CW_Type, First_Private_Entity);
-         Reinit_Field_To_Zero (CW_Type, Scope_Depth_Value);
-         Reinit_Field_To_Zero (CW_Type, SPARK_Aux_Pragma_Inherited);
+         if Ekind (CW_Type) in E_Task_Type | E_Protected_Type then
+            Reinit_Field_To_Zero (CW_Type, SPARK_Aux_Pragma_Inherited);
+         end if;
       end if;
 
       Mutate_Ekind                    (CW_Type, E_Class_Wide_Type);