comp.lang.ada
 help / color / mirror / Atom feed
* gneric package breaks the restriction of No_Elaboration_Code ?
@ 2011-02-28 10:26 ytomino
  2011-02-28 12:42 ` Simon Wright
  2011-02-28 13:03 ` ytomino
  0 siblings, 2 replies; 4+ messages in thread
From: ytomino @ 2011-02-28 10:26 UTC (permalink / raw)


Hello.
I found unnecessary elaboration code is generated
that is probably caused by generic instantiation.
Please look the sources in below:

---- t_g.ads ----
pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
generic
procedure t_g;
pragma Pure (t_g);
---- t_g.adb ----
pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
procedure t_g is
begin
   null;
end t_g;
---- t_i.ads ----
pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
with t_g;
package t_i is
   pragma Pure (t_i);
   procedure nested is new t_g; -- *1
end t_i;
---- t_m.adb ----
pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
with t_g;
package t_i is
   pragma Pure (t_i);
   procedure nested is new t_g;
end t_i;
-----------------

And comple these, look b~t_m.adb.

% gnatmake -g t_m
gcc -c -g t_m.adb
gcc -c -g t_i.ads
gcc -c -g t_g.adb
gnatbind -x t_m.ali
gnatlink t_m.ali -g

---- b~t_m.adb ----
...
   procedure adainit is
      E2 : Boolean; pragma Import (Ada, E2, "t_i_E");

   begin
      null;

      t_i'elab_spec; -- *2
      E2 := True;
   end adainit;
...
-------------------

Also, I used nm, found __elabs procedure.

% nm t_i.o
00000261 D _t_i_E
00000008 T _t_i___elabs
00000000 T _t_i__nested

Next, remove generic instantiation (*1), and re-compile these,
then, elaboration code disappeared from adainit in b~t_m.adb.

---- b~t_m.adb ----
...
   procedure adainit is

   begin
      null;

   end adainit;
...
-------------------

__elabs procedure disappeared too.

% nm t_i.o
00000025 D _t_i_E

I think this is gcc's bug. (I tried with gcc-4.5.1/4.5.2)
Or, possibly this is correct on the spec ?



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

end of thread, other threads:[~2011-03-07  8:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-28 10:26 gneric package breaks the restriction of No_Elaboration_Code ? ytomino
2011-02-28 12:42 ` Simon Wright
2011-03-07  8:51   ` ytomino
2011-02-28 13:03 ` ytomino

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