This is the mail archive of the 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] Crash on entry call with limited view of synchronized object

The prefix of an entry call may be a limited view, in which case the expansion
of the call must use the non-limited view, which is available at the point
of an entry call.

The following must compile quietly:

   gcc -c railway-train.adb

package Railway is
end Railway;
limited with Railway.Platform;
limited with Railway.Train;
package Railway.Common is
   --Common stuff
   type Train_Ref is access all Train.Train;
   type Platform_Ref is access all Platform.Platform;

   type Route_Range is range 1..100;
   type Route_Array is array (Route_Range) of Platform_Ref;
end Railway.Common;
with Railway.Common; use Railway.Common;
package Railway.Platform is

   protected type Platform is
      entry StopAtPlatform(Incoming_Train : in Train_Ref);
      procedure DepartFromPlatform;
      Train_At_Platform : Train_Ref := null;
   end Platform;
end Railway.Platform;
package body Railway.Platform is
   protected body Platform is

      -- Train occupies the platform. This stops the access to the platform
     --  by all other trains, until DepartFromPlatform is called
      entry StopAtPlatform(Incoming_Train : in Train_Ref)
          when Train_At_Platform = null is
         Train_At_Platform := Incoming_Train;
      end StopAtPlatform;
      --  Train leaves the platform. This re-opens access to the platform
      --  by all other trains
      procedure DepartFromPlatform is
         Train_At_Platform := null;
      end DepartFromPlatform;
   end Platform;
end Railway.Platform;
with Railway.Common; use Railway.Common;
with Ada.Text_IO; use Ada.Text_IO;
package Railway.Train is

   task type Train is
     entry Create(id : in Natural; capacity : in Positive; Route : Route_Array;
                   me : Train_Ref);
   end Train;
end Railway.Train;
with Railway.Platform;
package body Railway.Train is

   task body Train is
      Myself : Train_Ref;
      Train_ID : Natural;
      Passenger_Load : Integer := 0;
      Passenger_Capacity : Positive;
      Train_Route : Route_Array;
      accept Create (id : in Natural; capacity : in Positive;
                     Route : in Route_Array; me : Train_Ref) do
         Myself := me;
         Train_ID := id;
         Passenger_Capacity := capacity;
         Train_Route := Route;
      end Create;

         for i in Train_Route'Range loop
         end loop;
      end loop;
   end Train;
end Railway.Train;

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

2014-08-04  Ed Schonberg  <>

	* exp_ch9.adb (Extract_Entry): If the synchronized object is a
	limited view, replace with non-limited view, which is available
	at the point of an entry call.

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]