comp.lang.ada
 help / color / mirror / Atom feed
From: kylix <likai3g@gmail.com>
Subject: GNAT GPL 2012 bug of iterator?
Date: Tue, 26 Jun 2012 23:43:19 -0700 (PDT)
Date: 2012-06-26T23:43:19-07:00	[thread overview]
Message-ID: <a2fba8d4-f6c3-41e3-832c-37c580e779ab@googlegroups.com> (raw)

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;



             reply	other threads:[~2012-06-27  6:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-27  6:43 kylix [this message]
2012-06-27  7:46 ` GNAT GPL 2012 bug of iterator? Martin
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