From: Martin <martin@thedowies.com>
Subject: Re: GNAT GPL 2012 bug of iterator?
Date: Wed, 27 Jun 2012 00:46:20 -0700 (PDT)
Date: 2012-06-27T00:46:20-07:00 [thread overview]
Message-ID: <13ef2da8-c057-4727-9d1d-2bd516e37657@googlegroups.com> (raw)
In-Reply-To: <a2fba8d4-f6c3-41e3-832c-37c580e779ab@googlegroups.com>
On Wednesday, June 27, 2012 7:43:19 AM UTC+1, kylix wrote:
> I try to compile the test code under GNAT GPL 2012, and it give a error message:
> gcc -c -O2 test.adb
> test.adb:42:13: invalid prefix in selected component "c"
> gnatmake: "test.adb" compilation error
>
> It seems can't use list iterator in generic package.
>
> Here are the test code:
>
> pragma Ada_2012;
> with Ada.Text_IO;
> with Ada.Containers, Ada.Containers.Doubly_Linked_Lists;
> use Ada.Containers;
> procedure test is
>
> package Foo is
>
> type Rect_Type is tagged record
> w, h, a : Integer := 0;
> end record;
>
> procedure Calc (this : in out Rect_Type);
>
> type Rect_Ptr is access Rect_Type;
> end Foo;
>
> package body Foo is
>
> procedure Calc (this : in out Rect_Type) is
> begin
> this.a := this.w * this.h;
> end Calc;
>
> end Foo;
>
>
> generic
> package Generic_Pkg is
> use Foo;
> package Lists is new Doubly_Linked_Lists(Foo.Rect_Type);
>
> procedure Calc (list : in out Lists.List);
>
> end Generic_Pkg;
>
> package body Generic_Pkg is
>
> procedure Calc (list : in out Lists.List) is
> begin
> for c of list loop
> c.Calc; -- if this code not in generic package, it works fine
> end loop;
> end;
> end Generic_Pkg;
>
> package Rect is new Generic_Pkg;
>
> rs : Rect.Lists.List;
>
> begin
> for i in 1 .. 5 loop
> rs.Append ((others => i));
> end loop;
> Rect.Calc(rs);
> for c of rs loop
> Ada.Text_IO.Put_Line (Integer'Image(c.a));
> end loop;
> end test;
Same message in GNAT Pro 7.1.0 [actually GNAT Pro 7.1.0w (20120523-45)]
-- Martin
next prev parent reply other threads:[~2012-06-27 7:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 6:43 GNAT GPL 2012 bug of iterator? kylix
2012-06-27 7:46 ` Martin [this message]
2012-06-27 8:29 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox