http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48013
Summary: generic instantiation breaks the restriction of No_Elaboration_Code Product: gcc Version: 4.5.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada AssignedTo: unassig...@gcc.gnu.org ReportedBy: demoon...@panathenaia.halfmoon.jp Created attachment 23565 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23565 minimal bug triggering source code Unnecessary elaboration code is generated by generic instantiation with gcc-4.5.1/4.5.2/4.6.0(experimental at 20110225). 1. instantiate any generic package/subprogram in the library-level package. 2. gnatbind an application including this package. pragma Restrictions (No_Elaboration_Code) and pragma No_Run_Time are not effective in this problem. I expected that elaboration code will be removed or reported warning/error by Restrictions (No_Elaboration_Code). -- t_m.adb pragma Restrictions (No_Elaboration_Code); pragma No_Run_Time; with t_i; procedure t_m is begin null; end t_m; -- 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.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; -- *1 end t_i; % 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 Look adainit in b~t_m.adb. procedure adainit is E2 : Boolean; pragma Import (Ada, E2, "t_i_E"); begin null; t_i'elab_spec; -- it violates No_Elaboration_Code ! E2 := True; end adainit; % nm t_i.o 00000261 D _t_i_E 00000008 T _t_i___elabs 00000000 T _t_i__nested (Remove generic instantiation (*1), and re-compile these, then, elaboration code disappeared from adainit in b~t_m.adb and __elabs procedure disappeared from t_i.o too.)