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] Do not service entries after a protected function call (with -gnatp).


For single entry protected objects, the entry was served (in case of pending
call and when compiled without checks) after a function call. This is useless,
and not coherent with code generated without -gnatp.

The following program displays 'Barrier called' only three times:
gnatmake -gnatp main
./main
Barrier called
Barrier called
Barrier called

package prot is
  protected P is
    procedure proc;
    function fun return integer;
    entry en;
    procedure release;
  private
    released : boolean := false;
  end p;
end prot;

with ada.text_io; use ada.text_io;

package body prot is

  function Barrier return boolean is
  begin
     put_line ("Barrier called");
     return false;
  end Barrier;

  protected body P is
    procedure proc
    is
    begin
      null;
    end proc;

    function fun return integer is
    begin
      return 1;
    end fun;

    procedure release is
    begin
      released := true;
    end release;
    entry en when Barrier or else released is
    begin
      null;
    end en;
  end p;

  task T;
  task body T is
  begin
    P.en;
  end T;
end prot;

with prot;

procedure main is
  v : integer;
begin
   delay 1.0;
   v := prot.p.fun;
   prot.p.release;
end;

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

2014-01-27  Tristan Gingold  <gingold@adacore.com>

	* exp_ch7.adb (Build_Cleanup_Statements): Call
	Build_Protected_Subprogram_Call_Cleanup to insert the cleanup
	for protected body.
	* exp_ch9.adb (Build_Protected_Subprogram_Body): Likewise.
	 Remove Service_Name variable.
	(Build_Protected_SUbprogam_Call_Cleanup): New procedure that
	factorize code from the above subprograms.
	* exp_ch9.ads (Build_Protected_Subprogram_Call_Cleanup): New procedure.

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]