From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8e419b415c5d5311,start X-Google-Attributes: gid103376,public From: Damien Carbonne Subject: problem with generic instantiation (GNAT) Date: 2000/11/05 Message-ID: <3A06A7B3.2159F4A7@free.fr>#1/1 X-Deja-AN: 689873827 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@proxad.net X-Trace: nnrp1.proxad.net 973424320 212.27.37.221 (Sun, 05 Nov 2000 12:38:40 MET) Organization: Guest of ProXad - France MIME-Version: 1.0 NNTP-Posting-Date: Sun, 05 Nov 2000 12:38:40 MET Newsgroups: comp.lang.ada Date: 2000-11-05T00:00:00+00:00 List-Id: --> 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