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.
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);
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);