From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Gnat Problem - Freezing too soon Date: Thu, 28 Feb 2019 21:22:37 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: reader02.eternal-september.org; posting-host="b762c5e6fe84d6eb0ab322d3b03d0457"; logging-data="1119"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194f6ki8jowQwYGWQ6qvbeT0UQKQesFzf4=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:U7i6Rm9Pd+oXB6hd0unjgfyw5G0= sha1:yrQifun/lbovrwh4OO4O2f7wsQY= Xref: reader01.eternal-september.org comp.lang.ada:55723 Date: 2019-02-28T21:22:37+00:00 List-Id: --=-=-= Content-Type: text/plain russ lyttle 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: --=-=-= Content-Type: text/plain Content-Disposition: inline Content-Description: demo 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; --=-=-=--