diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-04-02 12:51:58 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-04-02 12:51:58 +0200 |
commit | cf5ba8a881c32483bc11e05cc1ee3bcc990d32c6 (patch) | |
tree | 168cc4772edea64b02c164aad0c4c50eb0e7c6fe /gcc/ada/sem_ch12.adb | |
parent | 5bd5034e244983cb1d6655a759efafcd5b6287aa (diff) | |
download | gcc-cf5ba8a881c32483bc11e05cc1ee3bcc990d32c6.zip gcc-cf5ba8a881c32483bc11e05cc1ee3bcc990d32c6.tar.gz gcc-cf5ba8a881c32483bc11e05cc1ee3bcc990d32c6.tar.bz2 |
[multiple changes]
2012-04-02 Robert Dewar <dewar@adacore.com>
* s-atopri.ads: Minor reformatting.
2012-04-02 Thomas Quinot <quinot@adacore.com>
* sem_util.adb: Minor reformatting, minor code cleanup.
2012-04-02 Ed Schonberg <schonberg@adacore.com>
* lib-xref.adb (Generate_Reference): For a reference to an
operator symbol, set the sloc to point to the first character
of the operator name, and not to the initial quaote.
(Output_References): Ditto for the definition of an operator
symbol.
2012-04-02 Vincent Celier <celier@adacore.com>
* ali.adb (Scan_Ali): Recognize Z lines. Set
Implicit_With_From_Instantiation to True in the With_Record for
Z lines.
* ali.ads (With_Record): New Boolean component
Implicit_With_From_Instantiation, defaulted to False.
* csinfo.adb: Indicate that Implicit_With_From_Instantiation
is special
* lib-writ.adb (Write_ALI): New array Implicit_With.
(Collect_Withs): Set Implicit_With for the unit is it is not Yes.
(Write_With_Lines): Write a Z line instead of a W line if
Implicit_With is Yes for the unit.
* sem_ch12.adb (Inherit_Context): Only add a unit in the context
if it is not there yet.
* sinfo.ads: New flag Implicit_With_From_Instantiation (Flag12)
added.
From-SVN: r186079
Diffstat (limited to 'gcc/ada/sem_ch12.adb')
-rw-r--r-- | gcc/ada/sem_ch12.adb | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index e516ec0..d052563 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -7761,6 +7761,9 @@ package body Sem_Ch12 is Item : Node_Id; New_I : Node_Id; + Clause : Node_Id; + OK : Boolean; + begin if Nkind (Parent (Gen_Decl)) = N_Compilation_Unit then @@ -7782,17 +7785,30 @@ package body Sem_Ch12 is while Present (Item) loop if Nkind (Item) = N_With_Clause then - -- Take care to prevent direct cyclic with's, which can happen - -- if the generic body with's the current unit. Such a case - -- would result in binder errors (or run-time errors if the - -- -gnatE switch is in effect), but we want to prevent it here, - -- because Sem.Walk_Library_Items doesn't like cycles. Note - -- that we don't bother to detect indirect cycles. + -- Take care to prevent direct cyclic with's. if Library_Unit (Item) /= Current_Unit then - New_I := New_Copy (Item); - Set_Implicit_With (New_I, True); - Append (New_I, Current_Context); + -- Do not add a unit if it is already in the context + + Clause := First (Current_Context); + OK := True; + while Present (Clause) loop + if Nkind (Clause) = N_With_Clause and then + Chars (Name (Clause)) = Chars (Name (Item)) + then + OK := False; + exit; + end if; + + Next (Clause); + end loop; + + if OK then + New_I := New_Copy (Item); + Set_Implicit_With (New_I, True); + Set_Implicit_With_From_Instantiation (New_I, True); + Append (New_I, Current_Context); + end if; end if; end if; |