From 1378bf105ea73f1d4fab574dc8ed6d1479433296 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 29 Aug 2011 12:19:00 +0200 Subject: [PATCH] [multiple changes] 2011-08-29 Gary Dismukes * sem_type.adb: Minor reformatting. 2011-08-29 Robert Dewar * makeutl.adb: Minor reformatting. 2011-08-29 Ed Schonberg * 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 --- gcc/ada/ChangeLog | 18 ++++++++++++++++++ gcc/ada/makeutl.adb | 14 +++++++++----- gcc/ada/sem_ch8.adb | 37 ++++++++++++++++++++++++++++--------- gcc/ada/sem_type.adb | 31 ++++++++++++++++++------------- 4 files changed, 73 insertions(+), 27 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0603a312e47..89975863d6e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,21 @@ +2011-08-29 Gary Dismukes + + * sem_type.adb: Minor reformatting. + +2011-08-29 Robert Dewar + + * makeutl.adb: Minor reformatting. + +2011-08-29 Ed Schonberg + + * 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. + 2011-08-29 Robert Dewar * exp_ch5.adb, sinfo.ads, make.adb, s-pooglo.adb, sem_ch12.adb, diff --git a/gcc/ada/makeutl.adb b/gcc/ada/makeutl.adb index c8cbd0522e3..848db592a1a 100644 --- a/gcc/ada/makeutl.adb +++ b/gcc/ada/makeutl.adb @@ -1560,13 +1560,17 @@ package body Makeutl is if Is_Absolute_Path (Main) then Main_Id := Create_Name (Base); + + -- Not an absolute path + else + -- Always resolve links here, so that users can be + -- specify any name on the command line. If the + -- project itself uses links, the user will be + -- using -eL anyway, and thus files are also stored + -- with resolved names. + declare - -- Always resolve links here, so that users - -- can be specify any name on the command line. - -- If the project itself uses links, the user - -- will be using -eL anyway, and thus files are - -- also stored with resolved names. Absolute : constant String := Normalize_Pathname (Name => Main, diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index cf623bef718..8a144623db7 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); diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb index f035f504651..70a94234d3e 100644 --- a/gcc/ada/sem_type.adb +++ b/gcc/ada/sem_type.adb @@ -569,31 +569,34 @@ package body Sem_Type is Ent : constant Entity_Id := Entity (N); H : Entity_Id; First_Interp : Interp_Index; + function Within_Instance (E : Entity_Id) return Boolean; -- Within an instance there can be spurious ambiguities between a local - -- entity and one declared outside of the instance. This can only - -- happen for subprograms, because otherwise the local entity hides the - -- outer one. For overloadable entities, this predicate determines - -- whether it is a candidate within the instance, or must be ignored. + -- entity and one declared outside of the instance. This can only happen + -- for subprograms, because otherwise the local entity hides the outer + -- one. For an overloadable entity, this predicate determines whether it + -- is a candidate within the instance, or must be ignored. + + --------------------- + -- Within_Instance -- + --------------------- function Within_Instance (E : Entity_Id) return Boolean is Inst : Entity_Id; Scop : Entity_Id; + begin if not In_Instance then return False; end if; + Inst := Current_Scope; - while Present (Inst) - and then not Is_Generic_Instance (Inst) - loop + while Present (Inst) and then not Is_Generic_Instance (Inst) loop Inst := Scope (Inst); end loop; - Scop := Scope (E); - while Present (Scop) - and then Scop /= Standard_Standard - loop + Scop := Scope (E); + while Present (Scop) and then Scop /= Standard_Standard loop if Scop = Inst then return True; end if; @@ -603,6 +606,8 @@ package body Sem_Type is return False; end Within_Instance; + -- Start of processing for Collect_Interps + begin New_Interps (N); @@ -660,8 +665,8 @@ package body Sem_Type is -- within the instance must not be included. if Within_Instance (H) - and then H /= Renamed_Entity (Ent) - and then not Is_Inherited_Operation (H) + and then H /= Renamed_Entity (Ent) + and then not Is_Inherited_Operation (H) then All_Interp.Table (All_Interp.Last) := (H, Etype (H), Empty);