This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Adding switch to disable implicit Elaborate_All in task case


This patch adds switch -gnatd.y to disable the generation of
implicit Elaborate_All on a package X when a task body calls
a procedure in the same package, and that procedure calls a
procedure in another package X.

As documented in the GNAT User Guide, when sources cannot be
modified, the recommended solution is the use of restriction
No_Entry_Calls_In_Elaboration_Code. This switch provides a
way to disable the generation of the implicit Elaborate_All
when that restriction is not applicable to the sources.

The following test now compiles without errors:

with Utils;
package body Decls is
  procedure Put_Val (Arg : Decls.My_Int) is
  begin
     Utils.Put_Val(Arg);
  end Put_Val;

  task body Lib_Task is
  begin
     accept Start;
     Put_Val (2); -- Utils.Put_Val(Arg);
  end Lib_Task;

  function Ident (M : My_Int) return My_Int is
  begin
     return M;
  end Ident;
end Decls;

package Decls is
  task Lib_Task is
     entry Start;
  end Lib_Task;

  type My_Int is new Integer;

  function Ident (M : My_Int) return My_Int;
end Decls;

with Decls;
procedure Main is
begin
   Decls.Lib_Task.Start;
end;

with Text_IO;
package body Utils is
  procedure Put_Val (Arg : Decls.My_Int) is
  begin
     Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg)));
  end Put_Val;
end Utils;

with Decls;
package Utils is
  procedure Put_Val (Arg : Decls.My_Int);
end Utils;

Command: gnatmake main.adb -gnatd.y

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-07  Javier Miranda  <miranda@adacore.com>

	* sem_elab.adb (Check_Task_Activation): Adding switch -gnatd.y to
	allow disabling the generation of implicit pragma Elaborate_All
	on task bodies.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]