diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-03-10 18:05:13 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2023-09-27 10:16:25 +0200 |
commit | 105309d2bb72a1c9e15014b01f390eca85f141ef (patch) | |
tree | faaaba2b2ec4f50b2a0b61a9933851c7fefbb849 /gcc | |
parent | ccd4972bbc2aece6b3d78b1ebee557e6f44a02f1 (diff) | |
download | gcc-105309d2bb72a1c9e15014b01f390eca85f141ef.zip gcc-105309d2bb72a1c9e15014b01f390eca85f141ef.tar.gz gcc-105309d2bb72a1c9e15014b01f390eca85f141ef.tar.bz2 |
ada: Fix internal error on declare-expression in post-condition
It comes from an incorrect node sharing in the expanded tree.
gcc/ada/
* sem_ch3.adb (Find_Type_Of_Object): Copy the object definition when
building the subtype declaration in the case of a spec expression.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_ch3.adb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index e462fa9..2e9f8aa 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -18425,19 +18425,21 @@ package body Sem_Ch3 is Analyze (Subtype_Mark (Obj_Def)); declare - Base_T : constant Entity_Id := Entity (Subtype_Mark (Obj_Def)); - Decl : constant Node_Id := + Base_T : constant Entity_Id := Entity (Subtype_Mark (Obj_Def)); + New_Def : constant Node_Id := New_Copy_Tree (Obj_Def); + Decl : constant Node_Id := Make_Subtype_Declaration (Sloc (P), Defining_Identifier => T, - Subtype_Indication => Relocate_Node (Obj_Def)); + Subtype_Indication => New_Def); + begin Set_Etype (T, Base_T); Mutate_Ekind (T, Subtype_Kind (Ekind (Base_T))); - Set_Parent (T, Obj_Def); + Set_Parent (T, Decl); Set_Scope (T, Current_Scope); if Ekind (T) = E_Array_Subtype then - Constrain_Array (T, Obj_Def, Related_Nod, T, 'P'); + Constrain_Array (T, New_Def, Related_Nod, T, 'P'); elsif Ekind (T) = E_Record_Subtype then Set_First_Entity (T, First_Entity (Base_T)); |