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] Inherited interface operations hidden by local declaration


When compiling a type extension with progenitors, we create local symbols for
the entries in secondary tables. For each interface primitive we locate the
operation that implements the primitive, or else the inherited abstract
operation that must eventually be overridden. This abstract operation is
normally introduced in the current scope, but it may be hidden because of a
local non-overloadable declaration. This patch adds a search through the
primitive operations of the type extension to locate the desired inherited
interface operation. This prevents crashes on programs where the extension
fails to implement the interface operation.

Compiling crash.adb must yield:

   crash.adb:7:04: interface subprogram "p" must be overridden

---
procedure Crash is
   package P is
      type A_Type is limited interface;
      procedure P (P : in out A_Type) is abstract;
   end P;
   
   protected type B_Type is new P.A_Type with
   end;
 
   protected body B_Type is
   end;
begin
   null;
end Crash;

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

2010-06-22  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb (Add_Internal_Interface_Entities): If
	Find_Primitive_Covering_Interface does not find the operation, it may
	be because of a name conflict between the inherited operation and a
	local non-overloadable name. In that case look for the operation among
	the primitive operations of the type. This search must succeed
	regardless of visibility.

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]