comp.lang.ada
 help / color / mirror / Atom feed
From: ytomino <aghia05@gmail.com>
Subject: Strange instantiation error with formal packages
Date: Mon, 18 Nov 2013 21:57:17 -0800 (PST)
Date: 2013-11-18T21:57:17-08:00	[thread overview]
Message-ID: <f04108fb-f007-44ec-8f9c-9d6772070606@googlegroups.com> (raw)

Hello.
Please, consider below example:

---- 8< ----

with ada.containers.ordered_sets; -- any generic package
with g1;
with g2;
procedure main is
   package charsets is new ada.containers.ordered_sets (Character);
   package p1 is new g1 (charsets);
   package p1_n is new p1.nested;
   package p2 is new g2 (charsets, p1, p1_n);
begin
   null;
end main;

with ada.containers.ordered_sets;
generic
   with package sets is new ada.containers.ordered_sets(<>);
package g1 is
   generic
   package nested is
   end nested;
end g1;

with ada.containers.ordered_sets;
with g1;
generic
   with package sets is new ada.containers.ordered_sets(<>); -- *1
   with package p1 is new g1 (sets);
   with package p1_n is new p1.nested;
package g2 is
end g2;

---- >8 ----

This is OK, able to be compiled.

$ gnatmake -gnat2012 main.adb
gcc -c -gnat2012 main.adb
gcc -c -gnat2012 g1.ads
gcc -c -gnat2012 g2.ads
gnatbind -x main.ali
gnatlink main.ali

Then...
Remove the formal package "sets" from g2:

---- 8< ----

with ada.containers.ordered_sets;
with g1;
with g2;
procedure main is
   package charsets is new ada.containers.ordered_sets (Character);
   package p1 is new g1 (charsets);
   package p1_n is new p1.nested;
   package p2 is new g2 (p1, p1_n); -- "sets" is removed
begin
   null;
end main;

-- g1 is same as first example.

with g1;
generic
   -- "sets" is removed
   with package p1 is new g1 (<>); -- use a box instead of "sets"
   with package p1_n is new p1.nested;
package g2 is
end g2;

---- >8 ----

This is bad.

$ gnatmake -gnat2012 main.adb
gcc -c -gnat2012 main.adb
main.adb:8:30: actual parameter must be instance of "nested"
main.adb:8:30: instantiation abandoned
gnatmake: "main.adb" compilation error

Why?

I tried with gcc-4.8.1 and GNAT GPL 2012.


Regards.

--
Yuta Tomino

             reply	other threads:[~2013-11-19  5:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  5:57 ytomino [this message]
2013-11-19 15:08 ` Strange instantiation error with formal packages AdaMagica
2013-11-19 15:45   ` Adam Beneschan
2013-11-19 20:14     ` Dmitry A. Kazakov
2013-11-21 14:05       ` ytomino
2013-11-21 13:54     ` ytomino
replies disabled

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