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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,287f73fa8b0c840d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Syntax question: new with a constrained subtype indication Date: Mon, 25 Apr 2005 18:07:45 +0200 Message-ID: <426D15D1.703@mailinator.com> References: <426d10d1$1_2@newsfeed.slurp.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net dP/Qt+tKCdiBCCaupOD09gd8jMiNbVV6b+ryGJTc2hxcBDFIM= User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en In-Reply-To: <426d10d1$1_2@newsfeed.slurp.net> Xref: g2news1.google.com comp.lang.ada:10687 Date: 2005-04-25T18:07:45+02:00 List-Id: James Alan Farrell wrote: > Hi all, > I'm working on software to analyze Ada programs using ASIS. As such I > need to make sure I handle all cases in the syntax (and I'm finding that > in past assignments I've used only a small portion of the whole language!) > > I'm currently working on a piece of code to analyze allocator > expressions (ARM 4.8). The entire relevant syntax is: > > 4.8: > allocator ::= > new subtype_indication | new qualified_expression > > 3.2.2: > subtype_indication ::= subtype_mark [constraint] > > 3.2.2: > subtype_mark ::= subtype_name > > 3.2.2: > constraint ::= scalar_constraint | composite_constraint > > 3.2.2: > scalar_constraint ::= > range_constraint | digits_constraint | delta_constraint > > 3.5 > range_constraint ::= range range > > 3.5: > range ::= range_attribute_reference > | simple_expression .. simple_expression > > From this, it appears I should be able to do something like: > > package body Mod1 is > > procedure Proc1 is > > type Vector is array (Integer range <>) of Float; > type VectorPtr is access Vector; > > V : VectorPtr; > > begin > V := new Vector range 1 .. 10; What I've done quite frequently is V := new Vector (1 .. 10); > end Proc1; > > end mod1; > > Using gnat 3.15p, I get this error: > > mod1.adb:15:23: incorrect constraint for this kind of type > gnatmake: "mod1.adb" compilation error > > I suspect this is a type issue, but let me know if there is something > incorrect in the syntax. > > The thing is, I've read 4.8 of the *annotated* ARM and I don't see > anything to say I cannot do this. So what am I missing? Is there > something, other than that document, that spells out the allowed types > of constraint? > > Thank you, > James Alan Farrell