comp.lang.ada
 help / color / mirror / Atom feed
* Elaboration problem with a task
@ 2006-01-05 10:04 JP Thornley
  2006-01-05 10:16 ` Martin Dowie
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: JP Thornley @ 2006-01-05 10:04 UTC (permalink / raw)


I'm getting an elaboration error and I don't understand why. It seems
to be caused by having a task in a package body that calls a procedure
in a child of that package.

Various restructurings, such as moving the task to a second child
package, have failed to clear the error.

I'm using Gnat 3.15p (GPS 2.1.0 on XP Pro).

The error goes away if I replace the direct call to the procedure in
the child (Child_C1.Proc1 in the code) by an indirect call to a local
procedure in the package body that then makes the call (Parent_Proc2)
but I guess that is only hiding the problem rather than solving it.


with Parent_P;
procedure Proc_P is
begin
    Parent_P.Parent_Proc1;
end Proc_P;


package Parent_P is
    procedure Parent_Proc1;
private
    Data1 : Integer;
end Parent_P;


with Parent_P.Child_C1;
package body Parent_P is

    procedure Parent_Proc1 is
    begin
       null;
    end Parent_Proc1;

    procedure Parent_Proc2 is
    begin
       Child_C1.Proc1 (Data1);
    end Parent_Proc2;

    task Parent_T;
    task body Parent_T is
    begin
       Child_C1.Proc1 (Data1);
    end Parent_T;

end Parent_P;


package Parent_P.Child_C1 is
    procedure Proc1 (P1 : in     Integer);
end Parent_P.Child_C1;


package body Parent_P.Child_C1 is

    procedure Proc1 (P1 : in     Integer) is
    begin
       null;
    end Proc1;

end Parent_P.Child_C1;


gnatbind -static -x proc_p.ali
error: elaboration circularity detected
info:    "parent_p (body)" must be elaborated before "parent_p (body)"
info:       reason: Elaborate_All probably needed in unit "parent_p 
(body)"
info:       recompile "parent_p (body)" with -gnatwl for full details
info:          "parent_p (body)"
info:             must be elaborated along with its spec:
info:          "parent_p (spec)"
info:             which is withed by:
info:          "parent_p.child_c1 (spec)"
info:             which is withed by:
info:          "parent_p (body)"

gnatmake: *** bind failed.


Adding pragma Elaborate_All(Parent_P.Child_C1); to the body of Parent_P
(as suggested) produces the same error except that the pragma is now
given as the reason for the circularity.

Using -gnatwl doesn't produce any additional information.

An unexpected part of the error message is that the body of Parent_P
"must be elaborated along with its spec". Can anyone explain why this is 
or otherwise suggest how to avoid the problem.

Cheers, and TIA,

Phil Thornley
-- 
JP Thornley



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-01-05 20:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-05 10:04 Elaboration problem with a task JP Thornley
2006-01-05 10:16 ` Martin Dowie
2006-01-05 11:13   ` JP Thornley
2006-01-05 14:18     ` Martin Dowie
2006-01-05 16:35       ` Pascal Obry
2006-01-05 19:34 ` Jeffrey R. Carter
2006-01-05 20:42 ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox