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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3b3dfe072ce73a8a X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Is this legal Ada95? Date: 1997/11/06 Message-ID: #1/1 X-Deja-AN: 287495360 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <63t88t$mqk$1@news.iastate.edu> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-11-06T00:00:00+00:00 List-Id: Kevin Radke (radke@cpre1.ee.iastate.edu) wrote: : I was compiling some Ada83 code originally written under VMS : and the Dec Ada compiler, and Gnat v3.10p on NT gives me : the following error: : foo.adb:11:56: object "Initial_Value" cannot be used before end : of its declaration : This code has compiled successfully on 3 Ada83 compilers and : 1 Ada95 compiler without problems. (This doesn't mean it is : correct, just no one else has complained about it.) I was : wondering if it is invalid somehow in Ada95 and the other : Ada95 compiler missed it, or if GNAT is being finicky. Looks OK to me (and our Ada 95 front end). GNAT 3.10p seems to be in the wrong here; it conceivably is being confused by your use of "Initial_Value" twice. You might try changing the name of the formal parameter in one of your generics to be something other than Initial_Value, and make the corresponding change in your instantiation of Double_Buffer.Interface. If this fixes the problem, then GNAT is apparently getting confused by the name reuse (though your use of the same names for both is in fact perfectly legal). : Thanks! : Kevin -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA : Here are the 3 files: : -- begin double_buffer.ads -- : package Double_Buffer is : generic : type Item_Type is private; : Initial_Value : in Item_Type; : package Interface is : procedure Put(Item : in Item_Type); : procedure Get(Item : out Item_Type); : end Interface; : end Double_Buffer; : -- end double_buffer.ads -- : -- begin foo.ads -- : generic : type Item_Type is private; : Initial_Value : in Item_Type; : package Foo is : type Time_Tag_Type is new Integer; : Null_Time_Tag : constant Time_Tag_Type := 0; : procedure Bar (Item : in Item_Type); : end Foo; : -- end foo.ads -- : -- begin foo.adb -- : with Double_Buffer; : package body Foo is : type Tagged_Item_Type is record : Item : Item_Type; : Time_Tag : Time_Tag_Type; : end record; : package My_Buffer is new : Double_Buffer.Interface (Tagged_Item_Type, : Initial_Value => (Item => Initial_Value, : Time_Tag => Null_Time_Tag)); : procedure Bar (Item : in Item_Type) is : begin : null; : end Bar; : end Foo; : -- end foo.adb --