]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] fix crash on Secondary_Stack_Size with discriminant
authorBob Duff <duff@adacore.com>
Fri, 28 Jan 2022 19:40:27 +0000 (14:40 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 11 May 2022 08:53:19 +0000 (08:53 +0000)
This patch fixes a crash caused by specifying the Secondary_Stack_Size
aspect of a task type as the value of a discriminant of the task type,
and then declaring a record component whose type is the task type,
constrained to a discriminant of the record.

gcc/ada/

* sem_ch3.adb (Get_Discr_Value): Copy the result. Otherwise, the
"tree" can be malformed (a DAG, not a tree) because
Get_Discr_Value could be returning some subtree already attached
to the tree.

gcc/ada/sem_ch3.adb

index 53b0ec994c914395f8f868cbf046b8d12e5c4319..d4464e2b8c9a7195374261a2962b6027fd50fed6 100644 (file)
@@ -13963,7 +13963,7 @@ package body Sem_Ch3 is
               or else D = CR_Discriminant (Discr_Id)
               or else Corresponding_Discriminant (D) = Discr_Id
             then
-               return Node (E);
+               return New_Copy_Tree (Node (E));
             end if;
 
             Next_Discriminant (D);
@@ -13987,7 +13987,7 @@ package body Sem_Ch3 is
             E := First_Elmt (Constraints);
             while Present (D) loop
                if D = Discr_Id then
-                  return Node (E);
+                  return New_Copy_Tree (Node (E));
                end if;
 
                Next_Discriminant (D);
This page took 0.077588 seconds and 5 git commands to generate.