* [Ada] Compiler hang with full inlining and use clause in parent private part
@ 2015-03-02 11:20 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2015-03-02 11:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]
When compiling a descendant instance unit use_clauses in parent units are
chained to simplify removal at end of compilation. Use_clauses that appear in
the private part of parent are chained when compiling the private part of
the descendant. To prevent circularities in the list, use_clauses in the
private part of an ancestor should not be chained if there is an intervening
parent whose private part is already installed.
The following must compile properly:
gcc -c -gnatn2 main.adbo
---
with P2;
with P3;
package body Main is
package P2_Instance is new P2.Instance (Boolean);
end;
---
package Main is
pragma Elaborate_Body;
end;
---
package G1 is
generic package Instance is end;
end;
---
generic package G2.Child is end;
package body G2 is
procedure P is begin null; end;
end;
---
generic package G2 is
procedure P;
pragma Inline (P);
end;
---
with G2.Child;
package P1.G2_Instance.Child_Instance is new P1.G2_Instance.Child;
---
with G2;
package P1.G2_Instance is new G2;
---
with G1;
package P1 is
private
package G1_Instance is new G1.Instance;
use G1_Instance;
end;
---
with P1.G2_Instance;
package body P2 is
package body Instance is
procedure R (X : T_Access) is begin null; end;
end Instance;
end;
---
package P2 is
generic
type T is private;
package Instance is
type T_Access is access all T;
procedure R (X : T_Access);
end Instance;
end;
---
with P1.G2_Instance.Child_Instance;
package body P3 is end;
---
with S;
package P3 is
pragma Elaborate_Body;
function F (S : Boolean) return Integer is (0);
function F (I : Integer) return Integer is (F(S.G(I)));
end;
---
package S is
function G (I : Integer) return Boolean;
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2015-03-02 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Chain_Use_Clause): Do not chain use clause from
ancestor to list of use clauses active in descendant unit if we
are within the private part of an intervening parent, to prevent
circularities in use clause list.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 660 bytes --]
Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb (revision 221113)
+++ sem_ch8.adb (working copy)
@@ -4026,6 +4026,15 @@
if not In_Open_Scopes (Pack) then
null; -- default as well
+ -- If the use clause appears in an ancestor and we are in the
+ -- private part of the immediate parent, the use clauses are
+ -- already installed.
+
+ elsif Pack /= Scope (Current_Scope)
+ and then In_Private_Part (Scope (Current_Scope))
+ then
+ null;
+
else
-- Find entry for parent unit in scope stack
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-02 11:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 11:20 [Ada] Compiler hang with full inlining and use clause in parent private part Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).