comp.lang.ada
 help / color / mirror / Atom feed
From: ytomino <aghia05@gmail.com>
Subject: gneric package breaks the restriction of No_Elaboration_Code ?
Date: Mon, 28 Feb 2011 02:26:40 -0800 (PST)
Date: 2011-02-28T02:26:40-08:00	[thread overview]
Message-ID: <f0c58e2d-0af4-4cc0-82e7-9f3a0a897787@a11g2000pri.googlegroups.com> (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 ?



             reply	other threads:[~2011-02-28 10:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 10:26 ytomino [this message]
2011-02-28 12:42 ` gneric package breaks the restriction of No_Elaboration_Code ? Simon Wright
2011-03-07  8:51   ` ytomino
2011-02-28 13:03 ` ytomino
replies disabled

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