public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Crash on entry call with limited view of synchronized object
@ 2014-08-04 10:45 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2014-08-04 10:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

[-- Attachment #1: Type: text/plain, Size: 2773 bytes --]

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;
   private
      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
      begin
         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
      begin
         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;
   begin
      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;

      loop
         for i in Train_Route'Range loop
            Train_Route(i).StopAtPlatform(Myself); 
         end loop;
      end loop;
   end Train;
end Railway.Train;

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

2014-08-04  Ed Schonberg  <schonberg@adacore.com>

	* 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 #2: difs --]
[-- Type: text/plain, Size: 661 bytes --]

Index: exp_ch9.adb
===================================================================
--- exp_ch9.adb	(revision 213536)
+++ exp_ch9.adb	(working copy)
@@ -12819,6 +12819,14 @@
          Ename   := Selector_Name (Prefix (Nam));
          Index   := First (Expressions (Nam));
       end if;
+
+      --  Through indirection, the type may actually be a limited view of a
+      --  concurrent type. When compiling a call, the non-limited view of the
+      --  type is visible.
+
+      if From_Limited_With (Etype (Concval)) then
+         Set_Etype (Concval, Non_Limited_View (Etype (Concval)));
+      end if;
    end Extract_Entry;
 
    -------------------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-04 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-04 10:45 [Ada] Crash on entry call with limited view of synchronized object Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).