This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Spurious ambiguity in instances


Within an instance, a spurious ambiguity may arise between a local subprogram
and the actual for a formal subprogram of the enclosing instance. Previously
the code only handled spurious ambiguities between two actuals or two local
subprograms.

The following must compile quietly:

---
function Cutdown (A1, B1, A2, B2 : Boolean) return Boolean is
  generic
     type T1 is private;
     A1, B1 : T1;
     type T2 is private;
     A2, B2 : T2;
     with function Eq (X1, Y1 : T1) return Boolean;
  package G1 is
     generic
       with function Eq (X2, Y2 : T2) return Boolean;
     function G2 return Boolean;
  end G1;

  package body G1 is
     function G2 return Boolean is
     begin
         return Eq (X1 => A1, Y1 => B1) and Eq (X2 => A2, Y2 => B2);
     end G2;
  end G1;

  package I1 is new G1 (Boolean, A1, B1, Boolean, A2, B2, "=");

  function I2 is new I1.G2 ("=");
 begin
  return I2;
 end Cutdown;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-29  Ed Schonberg  <schonberg@adacore.com>

	* sem_type.adb (Collect_Interps): Within an instance, collect a homonym
	that comes from an enclosing scope if it is not the renaming of an
	actual, to handle properly a spurious ambiguity in an instance.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]