comp.lang.ada
 help / color / mirror / Atom feed
* GNAT GPL 2012 bug of iterator?
@ 2012-06-27  6:43 kylix
  2012-06-27  7:46 ` Martin
  0 siblings, 1 reply; 3+ messages in thread
From: kylix @ 2012-06-27  6:43 UTC (permalink / 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;



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-27  8:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27  6:43 GNAT GPL 2012 bug of iterator? kylix
2012-06-27  7:46 ` Martin
2012-06-27  8:29   ` Georg Bauhaus

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