diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2022-06-06 10:50:23 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-07-05 08:28:18 +0000 |
commit | 69a70b0acbf01387ec1d1e85d2c7ed0d588d799e (patch) | |
tree | 67b7ab4aa3162168b8308da4ad940158aaedbf31 /gcc/ada/sem_ch3.adb | |
parent | 1d5018955a37fa665acc8dcba8121dd365dbe9be (diff) | |
download | gcc-69a70b0acbf01387ec1d1e85d2c7ed0d588d799e.zip gcc-69a70b0acbf01387ec1d1e85d2c7ed0d588d799e.tar.gz gcc-69a70b0acbf01387ec1d1e85d2c7ed0d588d799e.tar.bz2 |
[Ada] Perform object rewriting as renaming only in the expander
The rewriting as renaming optimization for object declarations is done
partly during analysis, guarded with Expander_Active, and partly during
expansion, so it makes sense to do it entirely during expansion.
This merges the two cases and removes obsolete or unnecessary conditions
guarding the transformation in the process.
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): Rewrite as a renaming
for any nonaliased local object with nominal unconstrained subtype
originally initialized with the result of a function call that has
been rewritten as the dereference of a reference to the result.
* sem_ch3.adb (Analyze_Object_Declaration): Do not do it here
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r-- | gcc/ada/sem_ch3.adb | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 29969b3..790d1d1 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -5048,41 +5048,6 @@ package body Sem_Ch3 is end; end if; - -- Another optimization: if the nominal subtype is unconstrained and - -- the expression is a function call that returns on the secondary - -- stack, rewrite the declaration as a renaming of the result of the - -- call. The exceptions below are cases where the copy is expected, - -- either by the back end (Aliased case) or by the semantics, as for - -- initializing controlled types or copying tags for class-wide types. - -- ??? To be moved to Expand_N_Object_Declaration.Rewrite_As_Renaming. - - if Present (E) - and then Nkind (E) = N_Explicit_Dereference - and then Nkind (Original_Node (E)) = N_Function_Call - and then not Is_Library_Level_Entity (Id) - and then not Is_Aliased (Id) - and then Needs_Secondary_Stack (T) - and then not Is_Class_Wide_Type (T) - and then not Needs_Finalization (T) - and then Expander_Active - then - Rewrite (N, - Make_Object_Renaming_Declaration (Loc, - Defining_Identifier => Id, - Access_Definition => Empty, - Subtype_Mark => New_Occurrence_Of - (Base_Type (Etype (Id)), Loc), - Name => E)); - - Set_Renamed_Object (Id, E); - - -- Force generation of debugging information for the constant and for - -- the renamed function call. - - Set_Debug_Info_Needed (Id); - Set_Debug_Info_Needed (Entity (Prefix (E))); - end if; - if Present (Prev_Entity) and then Is_Frozen (Prev_Entity) and then not Error_Posted (Id) |