comp.lang.ada
 help / color / mirror / Atom feed
From: George <geo.paok@gmail.com>
Subject: SPARK: Problem with using constants in a post annotation
Date: Thu, 13 Jan 2011 01:18:16 -0800 (PST)
Date: 2011-01-13T01:18:16-08:00	[thread overview]
Message-ID: <af7b3e83-d76b-4a65-831f-4251a1b2a51c@z5g2000yqb.googlegroups.com> (raw)

Hello,

I'm trying to use inside a post annotation two constants that are
declared in the package body. But, I can't do it, because the two
constants are not recognised at the point where they are used in the
annotation. Does anyone have an idea of how to overcome this problem?
Is it possible to overcome this by using only annotations without
changing the code?
The package specification and body, as well as the error messages are
shown below:

-- File P2.ads
--# inherit P1;
package P2
is
   procedure Control;
   --# global in out P1.Val;
   --# derives P1.Val from P1.Val;
   --# post (P1.Val <= [COLOR="Red"][B]C1[/B][/COLOR] -> P1.Val = 0)
and
   --#      (P1.Val >= [COLOR="Red"][B]C2[/B][/COLOR] -> P1.Val = 1);

end P2;


-- File P2.adb
with P1;
package body P2 is

   C1: constant P1.Type := 10;
   C2: constant P1.Type := 20;

   procedure Proc
   is
      V1: P1.Type;
   begin
      V1 := P1.Val;
      if V1 <= C1 then
         P1.Val := 0;
      elsif V1 >= C2 then
         P1.Val := 1;
      end if;
   end Proc;

end P2;


OUTPUT
13:30   Semantic Error   1 - The identifier C1 is either undeclared or
not visible at this point.
14:30   Semantic Error   1 - The identifier C2 is either undeclared or
not visible at this point.



             reply	other threads:[~2011-01-13  9:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13  9:18 George [this message]
2011-01-13  9:26 ` SPARK: Problem with using constants in a post annotation George
2011-01-13 11:15   ` Phil Thornley
2011-01-13 12:23     ` George
2011-01-17 11:08     ` Mark Lorenzen
2011-01-17 15:17       ` Phil Thornley
2011-01-17 16:13         ` Mark Lorenzen
2011-01-13 11:15   ` George
replies disabled

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