comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Thornley <phil.jpthornley@googlemail.com>
Subject: Re: Q: SPARK visibility rules and inherit annotations.
Date: Wed, 19 May 2010 08:54:56 -0700 (PDT)
Date: 2010-05-19T08:54:56-07:00	[thread overview]
Message-ID: <568bb04d-6ad6-46da-9eb2-8d81c8c52b59@v18g2000vbc.googlegroups.com> (raw)
In-Reply-To: 4bf3fce5$0$2399$4d3efbfe@news.sover.net

On 19 May, 16:04, "Peter C. Chapin" <pcc482...@gmail.com> wrote:
> I'm working on a SPARK program. Right now I'm just doing design so my focus is
> on package specifications; there are no package bodies. I'm having some
> trouble with the following:
>
> with TMLib.Cryptographic_Services;
>
> --# inherit TMLib.Cryptographic_Services;
> package TMLib.Credentials is
>    type Credential_Type is private;
>
>    -- Converts the raw bytes of a certificate transfer format to a credential.
>    procedure Certificate_To_Credential
>      (Raw_Data   : in TMLib.Cryptographic_Services.Octet_Array;
>       Credential : out Credential_Type;
>       Valid      : out Boolean);
>    --# derives Credential from Raw_Data &
>    --#         Valid      from Raw_Data;
>
>    -- Other stuff not shown here...
> end TMLib.Credentials;
>
> The SPARK Examiner complains about the use of "Cryptographic_Services" in the
> declaration of the Raw_Data parameter to the procedure. Specifically I get
> error 754 that says (roughly) "The identifier Cryptographic_Services is not
> declared or not visible." I am then told that I probably need both a 'with'
> statement in the context clause and an 'inherit' annotation. Don't I have
> those things?
>
> Note that TMLib.Cryptographic_Services examines without error but it does
> generate a warning because the private section is empty and currently hidden
> from SPARK with a 'hide' annotation. It seems unlikely to me that has
> anything to do with my problem. Note that TMLib.Cryptographic_Services is a
> public child of TMLib.
>
> I tried adding a 'with TMLib;' in the context clause but that didn't have any
> effect. I realize the problem is probably something silly but I'm a bit
> baffled here. Any pointers would be appreciated.
>
> Thanks!
>
> Peter

Peter,

The problem comes from the reference in one child of TMLib to another
child of TMLib.

Where this is the case, in the code and annotations - but not in the
inherit or context clauses - the common parent must not appear in the
name.

So change the line:
   (Raw_Data   : in TMLib.Cryptographic_Services.Octet_Array;
to:
   (Raw_Data   : in Cryptographic_Services.Octet_Array;

This comes from the rule that no entity in a SPARK program can have
more than one name - and in the Ada this type can be called either
TMLib.Cryptographic_Services.Octet_Array or
Cryptographic_Services.Octet_Array.

In SPARK the decision was to enforce the second of these.

(I'm sure that this is one error message that could be improved...)

Cheers,

Phil



  reply	other threads:[~2010-05-19 15:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19 15:04 Q: SPARK visibility rules and inherit annotations Peter C. Chapin
2010-05-19 15:54 ` Phil Thornley [this message]
2010-05-19 21:29   ` Peter C. Chapin
2010-05-20  1:47     ` Yannick Duchêne (Hibou57)
2010-05-20 11:03       ` Gavino
2010-05-20 15:58         ` Yannick Duchêne (Hibou57)
2010-05-21 10:42           ` Gavino
2010-05-25 20:58             ` Yannick Duchêne (Hibou57)
2010-05-19 16:22 ` Yannick Duchêne (Hibou57)
2010-05-19 20:41   ` Gavino
replies disabled

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