comp.lang.ada
 help / color / mirror / Atom feed
* Strange instantiation error with formal packages
@ 2013-11-19  5:57 ytomino
  2013-11-19 15:08 ` AdaMagica
  0 siblings, 1 reply; 6+ messages in thread
From: ytomino @ 2013-11-19  5:57 UTC (permalink / 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

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

end of thread, other threads:[~2013-11-21 14:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-19  5:57 Strange instantiation error with formal packages ytomino
2013-11-19 15:08 ` 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

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