comp.lang.ada
 help / color / mirror / Atom feed
* problem with generic instantiation (GNAT)
@ 2000-11-05  0:00 Damien Carbonne
  0 siblings, 0 replies; only message in thread
From: Damien Carbonne @ 2000-11-05  0:00 UTC (permalink / raw)


--> COMMENTS
--  GNAT chat does not seem to work at this time, and I think that the answer
--  to this problem is not GNAT specific, so I submit it to CLA.
--
--  I have derived this example to illustrate a problem I have with GNAT.
--  The problem appears in instantiation of Signature3 when actual types
--  for Type1 and Type2 are the same in instantiation of Signature1.
--
--  I don't understand why, on line (3), Equal is not taken as the one related
--  to Type1 (on line (1)).
--  It seems that the instantiation works as if a "macro substitution" was done
--  first, loosing the initial declarations. The compiler being then confused
--  by lines (1) and (2) that become identical after this substitution.
--
--  I don't know GNAT if is right:
--  o if yes, a better message (more explicit about ambiguity)
--    would really be helpful.
--  o if not, it is a bug that should be corrected.
--
--  Thank you for answers.

--> COMPILER
--> GNAT 3.13p (20000509) (i686-pc-linux-gnu)

--> COMMANDS
--|#! /bin/sh
--| gnatchop -w $1
--| gnatmake -c instances.ads -gnatfv

--> SOURCES
-----------------------------------------------------------
generic
   type Type1 is private;
   with function Equal (Left, Rigth : Type1) return Boolean; -- (1)
   type Type2 is private;
   with function Equal (Left, Rigth : Type2) return Boolean; -- (2)
package Signature1 is
end Signature1;
-----------------------------------------------------------
generic
   type Type1 is private;
   with function Equal (Left, Right : Type1) return Boolean;
package Signature2 is
end Signature2;
-----------------------------------------------------------
with Signature1;
with Signature2;
generic
   with package S1 is new Signature1 (<>);
   use S1;
package Signature3 is
   package S2 is new Signature2 (Type1, Equal); -- (3)
end Signature3;
-----------------------------------------------------------
with Signature1;
with Signature3;
package Instances is
   subtype Type1 is Integer;
   subtype Type2 is Integer;
   package S1 is new Signature1 (Type1, "=", Type2, "=");
   package S3 is new Signature3 (S1);
end Instances;

--> RESULTS
--  splitting rep20001104-3.13p-a.txt into:
--     signature1.ads
--     signature2.ads
--     signature3.ads
--     instances.ads
--  gcc -c -gnatfv instances.ads
--
--  GNAT 3.13p  (20000509) Copyright 1992-2000 Free Software Foundation, Inc.
--
--  Compiling: instances.ads (source file time stamp: 2000-11-06 12:32:11)
--
--       8.    package S3 is new Signature3 (S1);
--             |
--          >>> instantiation error at signature3.ads:8
--          >>> ambiguous renaming
--
--   29 lines: 2 errors
--  gnatmake: "instances.ads" compilation error





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-11-05  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-05  0:00 problem with generic instantiation (GNAT) Damien Carbonne

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