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] Rederivation of interface primitives


When a private extension  is completed by a full declaration, a visible
primitive operation of the parent type will be derived twice. The derivation
produced for the full type declaration must be ignored so that the one
associated with the visible partial view is available to clients. This patch
extends the corresponding check to the case where the parent type is an
interface type.

The following must compile quietly:

   gcc -c -gnat05 proxy.adb

---
with Pere, Fils;
package Proxy is

   type T_Proxy is new Pere.T_Pere with private;

   overriding function Action_Pere (This : in T_Proxy) return Boolean;

private
   type T_Proxy is new Pere.T_Pere with record
      Un_Fils : Fils.T_Fils_Class_Access;
   end record;
end Proxy;
---
package body Proxy is
   use Fils;

   function Action_Pere (This : in T_Proxy) return Boolean is
   begin
      return This.Un_Fils.Action_pere;
   end Action_Pere;
end Proxy;
---
with Pere;
package Fils is

   type T_Fils is abstract new Pere.T_Pere with private;

   type T_Fils_Class_Access is access all T_Fils'Class;

   function Action_Fils (This : in T_Fils) return Boolean;

private
     type T_Fils is abstract new Pere.T_Pere with null record;
end Fils;
---
package body Fils is
   function Action_Fils (This : in T_Fils) return Boolean is
   begin
      return T_Fils'Class (This).Action_Pere;
   end Action_Fils;
end Fils;
---
package Pere is
   type T_Pere is limited interface;

   function Action_Pere (This : in T_Pere) return Boolean is abstract;

end Pere;
---

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

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

	* sem_ch6.adb (New_Overloaded_Entity): If the new entity is a
	rederivation associated with a full declaration in a private part, and
	there is a partial view that derives the same parent subprogram, the
	new entity does not become visible. This check must be applied to
	interface operations as well.

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]