comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Gnat Problem - Freezing too soon
Date: Thu, 28 Feb 2019 21:22:37 +0000
Date: 2019-02-28T21:22:37+00:00	[thread overview]
Message-ID: <lyfts7ip5u.fsf@pushface.org> (raw)
In-Reply-To: q599k3$1t6e$1@gioia.aioe.org

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

russ lyttle <lyttlec@removegmail.com> writes:

> Example from the bookAnalysable Real-Time Systems :
>
> 1  package Environment_Monitor.Ch4_Status is --Protected
> 2    protected type Methane_Agent (Ceiling : Priority)
> 3     with Priority => Ceiling
> 4       is new CH4_Safety
> 5    with
> 6      overriding function Check_Safe return Methane_Status;
> 7      overriding procedure Set_Safety (M : Methane_Status);
> 8    private
> 9       Current_Status : Methane_Status := Motor_Unsafe;
> 10   end Methane_Agent;
> 11 end Environment_Monitor.Ch4_Status;
>
> Gnat complains that Methane_Agent is frozen at line 2, and line 3 is
> trying to change an attribute after being frozen.

The resolution may well be to upgrade your compiler. GNAT GPL 2017 and
FSF GCC 8 are both happy with this compilable demonstrator:


[-- Attachment #2: demo --]
[-- Type: text/plain, Size: 1015 bytes --]

with System;
with Ada.Text_IO;
procedure Russ is

   package P is

      type Parent is synchronized interface;
      function Is_Safe (P : Parent) return Boolean is abstract;
      procedure Set_Safety (P : in out Parent; To : Boolean) is abstract;

      protected type Child (Ceiling : System.Priority)
      with Priority => Ceiling
      is new Parent with
         overriding
         function Is_Safe return Boolean;
         overriding
         procedure Set_Safety (To : Boolean);
      private
         Safety : Boolean := False;
      end Child;

   end P;

   package body P is

      protected body Child is
         function Is_Safe return Boolean is (Safety);
         procedure Set_Safety (To : Boolean) is
         begin
            Safety := To;
         end Set_Safety;
      end Child;

   end P;

   A_Child : P.Child (Ceiling => System.Priority'Last);

begin
   Ada.Text_IO.Put_Line (A_Child.Is_Safe'Img);
   A_Child.Set_Safety (True);
   Ada.Text_IO.Put_Line (A_Child.Is_Safe'Img);
end Russ;

  parent reply	other threads:[~2019-02-28 21:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 18:34 Gnat Problem - Freezing too soon russ lyttle
2019-02-28 21:19 ` Anh Vo
2019-02-28 21:31   ` russ lyttle
2019-02-28 21:22 ` Simon Wright [this message]
2019-02-28 22:11   ` russ lyttle
2019-03-01  0:49     ` Anh Vo
2019-03-01 14:21       ` russ lyttle
2019-03-01 16:54         ` Anh Vo
2019-03-01 21:50           ` russ lyttle
2019-03-02  1:08             ` Anh Vo
2019-03-02  3:55               ` russ lyttle
2019-03-02  5:50                 ` Anh Vo
2019-03-02 20:19                   ` russ lyttle
2019-03-02 21:35                     ` Simon Wright
2019-03-03 20:42                       ` russ lyttle
2019-03-03 21:26                         ` Simon Wright
2019-03-04  0:33                           ` russ lyttle
2019-03-02 14:09             ` Simon Wright
2019-03-01  8:12     ` Simon Wright
2019-03-01 14:17       ` russ lyttle
2019-03-01 18:10     ` Simon Wright
2019-03-01 21:35       ` russ lyttle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox