diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2024-02-23 13:57:27 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-16 10:49:31 +0200 |
commit | f5c78702f9436bfa5a0cf1f87b6004ead79c5892 (patch) | |
tree | 5db29ad64d92d7ca166f195d132a9cc4ce9029d3 | |
parent | 7d2a5dbbfed311b9d13e5772dbc86f525adde3e9 (diff) | |
download | gcc-f5c78702f9436bfa5a0cf1f87b6004ead79c5892.zip gcc-f5c78702f9436bfa5a0cf1f87b6004ead79c5892.tar.gz gcc-f5c78702f9436bfa5a0cf1f87b6004ead79c5892.tar.bz2 |
ada: No need to follow New_Occurrence_Of with Set_Etype
Routine New_Occurrence_Of itself sets the Etype of its result; there is
no need to set it explicitly afterwards.
Code cleanup related to fix for attribute 'Old; semantics is unaffected.
gcc/ada/
* exp_ch13.adb (Expand_N_Free_Statement): After analysis, the
new temporary has the type of its Object_Definition and the new
occurrence of this temporary has this type as well; simplify.
* sem_util.adb
(Indirect_Temp_Value): Remove redundant call to Set_Etype;
simplify.
(Is_Access_Type_For_Indirect_Temp): Add missing body header.
-rw-r--r-- | gcc/ada/exp_ch13.adb | 9 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/gcc/ada/exp_ch13.adb b/gcc/ada/exp_ch13.adb index 2d5ee9b..af8c925 100644 --- a/gcc/ada/exp_ch13.adb +++ b/gcc/ada/exp_ch13.adb @@ -358,21 +358,16 @@ package body Exp_Ch13 is declare Expr_Typ : constant Entity_Id := Etype (Expr); Loc : constant Source_Ptr := Sloc (N); - New_Expr : Node_Id; - Temp_Id : Entity_Id; + Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T'); begin - Temp_Id := Make_Temporary (Loc, 'T'); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Temp_Id, Object_Definition => New_Occurrence_Of (Expr_Typ, Loc), Expression => Relocate_Node (Expr))); - New_Expr := New_Occurrence_Of (Temp_Id, Loc); - Set_Etype (New_Expr, Expr_Typ); - - Set_Expression (N, New_Expr); + Set_Expression (N, New_Occurrence_Of (Temp_Id, Loc)); end; end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 766cabf..5ebb131 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -31081,8 +31081,7 @@ package body Sem_Util is begin if Is_Anonymous_Access_Type (Typ) then -- No indirection in this case; just evaluate the temp. - Result := New_Occurrence_Of (Temp, Loc); - Set_Etype (Result, Etype (Temp)); + return New_Occurrence_Of (Temp, Loc); else Result := Make_Explicit_Dereference (Loc, @@ -31101,11 +31100,15 @@ package body Sem_Util is Set_Etype (Result, Typ); end if; - end if; - return Result; + return Result; + end if; end Indirect_Temp_Value; + -------------------------------------- + -- Is_Access_Type_For_Indirect_Temp -- + -------------------------------------- + function Is_Access_Type_For_Indirect_Temp (T : Entity_Id) return Boolean is begin |