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] Visibility of private operations in prefixed calls


When resolving a prefixed call of the form Obj.Subp, there must be a visible
Subp declared for an ancestor of the type of Obj. If Subp is an overriding
declared in the private part of the package of the type of Obj, it is
labelled as hidden, but it is nevertheless a candidate interpretation if
there is an inherited operation in the visible part of the package. This
operation does not come from source, and its alias is the hidden Subp itself.

The following must compile quietly:

package P1 is
   type Root is tagged null record;
   procedure Parse (Obj : in out Root);
end;
---
with P1; use P1;
package P2 is
   type Child1 is new Root with private;
private
   type Child1 is new Root with null record;
   procedure Parse (Obj : in out Child1);
end;
---
with P2; use P2;
package P3 is
   type Grand is new Child1 with private;
private
   type Grand is new Child1 with null record;
   procedure Parse (Obj : in out Grand);
end;
---
with P3; use P3;
procedure Try is
  Thing : Grand;
begin
  Thing.Parse;
  Parse (Thing);
end;

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

2009-07-23  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch4.adb (Try_Primitive_Operation): A primitive operation is a
	valid candidate interpretation in a prefixed view if it is hidden, but
	overrides an inherited operation declared in the visible part.

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]