diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-09-10 12:28:45 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-09-10 12:28:45 +0200 |
commit | be257e995d7fc59dcdbfcdbb8d549a4418d97f3b (patch) | |
tree | cc649ae7918e41381652fd2f8884f189f3be98bc /gcc/ada/sem.adb | |
parent | af80460358e29d5051bebf3046765412f88574da (diff) | |
download | gcc-be257e995d7fc59dcdbfcdbb8d549a4418d97f3b.zip gcc-be257e995d7fc59dcdbfcdbb8d549a4418d97f3b.tar.gz gcc-be257e995d7fc59dcdbfcdbb8d549a4418d97f3b.tar.bz2 |
[multiple changes]
2010-09-10 Ed Schonberg <schonberg@adacore.com>
* sprint.adb (Sprint_Node_Actual, case N_Derived_Type_Definition): Do
not reset Sloc when printing keyword "new".
2010-09-10 Vincent Celier <celier@adacore.com>
* gnatcmd.adb (GNATCmd): Put the command line in environment variable
GNAT_DRIVER_COMMAND_LINE.
2010-09-10 Ed Schonberg <schonberg@adacore.com>
* sem.adb (Do_Unit_And_Dependents): if Withed_Body is set on a context
clause, process the body at once.
2010-09-10 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb (Resolve_Type_Conversion): Do not warn on a redundant
conversion is the expression is a qualified expression used to
disambiguate a function call.
2010-09-10 Vincent Celier <celier@adacore.com>
* prj-nmsc.adb (Add_Source): Allow an Ada source to have the same name
as a source of another project and of another language.
2010-09-10 Robert Dewar <dewar@adacore.com>
* prj-util.adb: Minor reformatting.
From-SVN: r164159
Diffstat (limited to 'gcc/ada/sem.adb')
-rw-r--r-- | gcc/ada/sem.adb | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index 90304b3..bf41936 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -1538,16 +1538,7 @@ package body Sem is -- This is needed because the spec of the main unit may appear in the -- context of some other unit. We do not want this to force processing -- of the main body before all other units have been processed. - - function Depends_On_Main (CU : Node_Id) return Boolean; - -- The body of a unit that is withed by the spec of the main unit - -- may in turn have a with_clause on that spec. In that case do not - -- traverse the body, to prevent loops. It can also happen that the - -- main body has a with_clause on a child, which of course has an - -- implicit with on its parent. It's OK to traverse the child body - -- if the main spec has been processed, otherwise we also have a - -- circularity to avoid. - + -- -- Another circularity pattern occurs when the main unit is a child unit -- and the body of an ancestor has a with-clause of the main unit or on -- one of its children. In both cases the body in question has a with- @@ -1556,6 +1547,14 @@ package body Sem is -- spec of a subprogram declared in an instance within the parent will -- not be seen in the main unit. + function Depends_On_Main (CU : Node_Id) return Boolean; + -- The body of a unit that is withed by the spec of the main unit may in + -- turn have a with_clause on that spec. In that case do not traverse + -- the body, to prevent loops. It can also happen that the main body has + -- a with_clause on a child, which of course has an implicit with on its + -- parent. It's OK to traverse the child body if the main spec has been + -- processed, otherwise we also have a circularity to avoid. + procedure Do_Action (CU : Node_Id; Item : Node_Id); -- Calls Action, with some validity checks @@ -1960,10 +1959,16 @@ package body Sem is -- a package, the original file carries the body, and the spec -- appears as a later entry in the units list. - -- Otherwise Bodies appear in the list only because of inlining - -- or instantiations, and they are processed only if relevant - -- to the main unit. The main unit itself is processed - -- separately after all other specs. + -- Otherwise bodies appear in the list only because of inlining + -- or instantiations, and they are processed only if relevant. + -- The flag Withed_Body on a context clause indicates that a + -- unit contains an instantiation that may be needed later, + -- and therefore the body that contains the generic body (and + -- its context) must be traversed immediately after the + -- corresponding spec (see Do_Unit_And_Dependents). + + -- The main unit itself is processed separately after all other + -- specs, and relevant bodies are examined in Process_Main. when N_Subprogram_Body => if Acts_As_Spec (N) then @@ -2181,6 +2186,8 @@ package body Sem is pragma Assert (Nkind (CU) = N_Compilation_Unit); Context_Item : Node_Id; + Lib_Unit : Node_Id; + Body_CU : Node_Id; begin Context_Item := First (Context_Items (CU)); @@ -2189,7 +2196,28 @@ package body Sem is and then (Include_Limited or else not Limited_Present (Context_Item)) then - Action (Library_Unit (Context_Item)); + Lib_Unit := Library_Unit (Context_Item); + Action (Lib_Unit); + + -- If the context item indicates that a package body is needed + -- because of an instantiation in CU, traverse the body now, + -- even if CU is not related to the main unit. + + if Present (Withed_Body (Context_Item)) + and then Present (Corresponding_Body (Unit (Lib_Unit))) + then + Body_CU := + Parent + (Unit_Declaration_Node + (Corresponding_Body (Unit (Lib_Unit)))); + + -- A body may have an implicit with on its own spec, in which + -- case we must ignore this context item to prevent looping. + + if Unit (CU) /= Unit (Body_CU) then + Action (Body_CU); + end if; + end if; end if; Context_Item := Next (Context_Item); |