diff options
author | Bob Duff <duff@adacore.com> | 2021-05-19 07:52:32 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-07-07 16:23:15 +0000 |
commit | ebef9784ef665511b407ed9081153a7eb52f816b (patch) | |
tree | 7b69b32a89f6657f3a78d1f03dedc9051a19a604 | |
parent | a7f66404a62179ed8d759e8d454635f775cef016 (diff) | |
download | gcc-ebef9784ef665511b407ed9081153a7eb52f816b.zip gcc-ebef9784ef665511b407ed9081153a7eb52f816b.tar.gz gcc-ebef9784ef665511b407ed9081153a7eb52f816b.tar.bz2 |
[Ada] Unchecked_Convert_To: set Parent
gcc/ada/
* tbuild.adb (Unchecked_Convert_To): Set the Parent of the new
node to the Parent of the old node.
* tbuild.ads (Unchecked_Convert_To): Document differences
between Convert_To and Unchecked_Convert_To. The previous
documentation claimed they are identical except for the
uncheckedness of the conversion.
-rw-r--r-- | gcc/ada/tbuild.adb | 13 | ||||
-rw-r--r-- | gcc/ada/tbuild.ads | 5 |
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/ada/tbuild.adb b/gcc/ada/tbuild.adb index e718644..4d9c1c4 100644 --- a/gcc/ada/tbuild.adb +++ b/gcc/ada/tbuild.adb @@ -919,10 +919,15 @@ package body Tbuild is -- All other cases else - Result := - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => New_Occurrence_Of (Typ, Loc), - Expression => Relocate_Node (Expr)); + declare + Expr_Parent : constant Node_Id := Parent (Expr); + begin + Result := + Make_Unchecked_Type_Conversion (Loc, + Subtype_Mark => New_Occurrence_Of (Typ, Loc), + Expression => Relocate_Node (Expr)); + Set_Parent (Result, Expr_Parent); + end; end if; Set_Etype (Result, Typ); diff --git a/gcc/ada/tbuild.ads b/gcc/ada/tbuild.ads index f2f9809..eb17865 100644 --- a/gcc/ada/tbuild.ads +++ b/gcc/ada/tbuild.ads @@ -340,7 +340,10 @@ package Tbuild is (Typ : Entity_Id; Expr : Node_Id) return Node_Id; -- Like Convert_To, but if a conversion is actually needed, constructs an - -- N_Unchecked_Type_Conversion node to do the required conversion. + -- N_Unchecked_Type_Conversion node to do the required conversion. Unlike + -- Convert_To, a new node is not required if Expr is already of the correct + -- BASE type, and if a new node is created, the Parent of Expr is copied to + -- it. ------------------------------------- -- Subprograms for Use by Gnat1drv -- |