diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-29 12:19:00 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-29 12:19:00 +0200 |
commit | 1378bf105ea73f1d4fab574dc8ed6d1479433296 (patch) | |
tree | 28305a5dec129da5c93001b73f0d5239be6459fe /gcc/ada/sem_ch8.adb | |
parent | 164e06c6c1fcb98089ed09959d251376ca1717dc (diff) | |
download | gcc-1378bf105ea73f1d4fab574dc8ed6d1479433296.zip gcc-1378bf105ea73f1d4fab574dc8ed6d1479433296.tar.gz gcc-1378bf105ea73f1d4fab574dc8ed6d1479433296.tar.bz2 |
[multiple changes]
2011-08-29 Gary Dismukes <dismukes@adacore.com>
* sem_type.adb: Minor reformatting.
2011-08-29 Robert Dewar <dewar@adacore.com>
* makeutl.adb: Minor reformatting.
2011-08-29 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Analyze_Object_Renaming): If the renamed object is a
function call of a limited type, the expansion of the renaming is
complicated by the presence of various temporaries and subtypes that
capture constraints of the renamed object.
Rewrite node as an object declaration, whose expansion is simpler.
Given that the object is limited there is no copy involved and no
performance hit.
From-SVN: r178187
Diffstat (limited to 'gcc/ada/sem_ch8.adb')
-rw-r--r-- | gcc/ada/sem_ch8.adb | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index cf623be..8a14462 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -682,9 +682,10 @@ package body Sem_Ch8 is ----------------------------- procedure Analyze_Object_Renaming (N : Node_Id) is - Id : constant Entity_Id := Defining_Identifier (N); + Loc : constant Source_Ptr := Sloc (N); + Id : constant Entity_Id := Defining_Identifier (N); Dec : Node_Id; - Nam : constant Node_Id := Name (N); + Nam : constant Node_Id := Name (N); T : Entity_Id; T2 : Entity_Id; @@ -704,7 +705,6 @@ package body Sem_Ch8 is ------------------------------ procedure Check_Constrained_Object is - Loc : constant Source_Ptr := Sloc (N); Subt : Entity_Id; begin @@ -805,6 +805,29 @@ package body Sem_Ch8 is Resolve (Nam, T); + -- If the renamed object is a function call of a limited type, + -- the expansion of the renaming is complicated by the presence + -- of various temporaries and subtypes that capture constraints + -- of the renamed object. Rewrite node as an object declaration, + -- whose expansion is simpler. Given that the object is limited + -- there is no copy involved and no performance hit. + + if Nkind (Nam) = N_Function_Call + and then Is_Immutably_Limited_Type (Etype (Nam)) + and then not Is_Constrained (T) + and then Comes_From_Source (N) + then + Set_Etype (Id, T); + Set_Ekind (Id, E_Constant); + Rewrite (N, + Make_Object_Declaration (Loc, + Defining_Identifier => Id, + Constant_Present => True, + Object_Definition => New_Occurrence_Of (T, Loc), + Expression => Relocate_Node (Nam))); + return; + end if; + -- Check that a class-wide object is not being renamed as an object -- of a specific type. The test for access types is needed to exclude -- cases where the renamed object is a dynamically tagged access @@ -2330,9 +2353,7 @@ package body Sem_Ch8 is -- of a generic, its entity is set to the first available homonym. -- We must first disambiguate the name, then set the proper entity. - if Is_Actual - and then Is_Overloaded (Nam) - then + if Is_Actual and then Is_Overloaded (Nam) then Set_Entity (Nam, Old_S); end if; end if; @@ -2403,9 +2424,7 @@ package body Sem_Ch8 is end if; if Old_S /= Any_Id then - if Is_Actual - and then From_Default (N) - then + if Is_Actual and then From_Default (N) then -- This is an implicit reference to the default actual Generate_Reference (Old_S, Nam, Typ => 'i', Force => True); |