From: Bill Keen <billy@marnhull.demon.co.uk>
Subject: Elaboration of nested packages.
Date: 1997/06/18
Date: 1997-06-18T00:00:00+00:00 [thread overview]
Message-ID: <yrQ8RCAF8EqzEwgc@marnhull.demon.co.uk> (raw)
The following piece of code expresses the essence of a problem I am
having in an Ada project using Ada83 and an old Alsys cross compiler. I
brought the fragment home to exercise it using GNAT 3.07 on DOS, and I
am more confused than ever.
with Ada.text_io; use Ada.text_io;
procedure P is
package OP is
generic
package IG is
end IG;
end OP;
package PI is new OP.IG; -- Is this ok?
package body OP is
package body IG is
begin
put_line("Elaborated body IG");
end;
begin
put_line("Elaborated body OP");
end;
begin
put_line("Main program");
end P;
When I run the program it generates I get:
Elaborated body OP
Main program
If I move the instantiation of OP.IG to below the body of OP the result
seems quite logical as it prints:
Elaborated body OP
Elaborated body IG
Main program
The first case baffles me. Does it never instantiate IG?
The investigation started when I thought in Ada83 this should raise
Program_error because of access before elaboration. I haven't run this
exact example on the Alsys compiler yet, but similar examples compile
and run ok. The LRM(83) 11.1-7 says (of Program_error) "This exception
is raised upon an attempt ... to elaborate a generic instantiation if
the body of the corresponding unit has not been elaborated." Surely the
instantiation of OP.IG qualifies.
I can't find a statement corresponding to 11.1-7 in the Ada95 RM. Has
the meaning of program_error changed in Ada95?
--
Bill Keen
next reply other threads:[~1997-06-18 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-18 0:00 Bill Keen [this message]
1997-06-19 0:00 ` Elaboration of nested packages Robert A Duff
1997-06-20 0:00 ` Robert Dewar
1997-06-22 0:00 ` Bill Keen
1997-06-22 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox