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] Private with_clauses and subunits


Private with_clauses are installed when compiling the private part of a package
declaration, or when compiling a package body.  They must also be installed
when compiling a subunit, after the compilation environment has been properly
removed in order to compile the context of the subunit by itself. This patch
forces the installation of these private_with clauses whenever the context of
a package body is established. These clauses must still be installed/removed
explicitly when compiling a nested package declaration, which is why they still
have to be handled elsewhere than in sem_ch10.

The following must compile quietly.

package body Cannon_Fields is

   procedure Emit_Angle_Changed
    (Self      : not null access Cannon_Field'Class;
     New_Angle : Integer)
       is separate;

   procedure Paint_Event
    (Self  : not null access Cannon_Field;
     Event : not null access Paint_Events.Q_Paint_Event'Class)
   is
   begin
      null;
   end Paint_Event;

end Cannon_Fields;
private with Paint_Events;

package Cannon_Fields is
   type Cannon_Field is tagged limited private;
private

   type Cannon_Field is tagged limited record
      null;
   end record;

   procedure Paint_Event
    (Self  : not null access Cannon_Field;
     Event : not null access Paint_Events.Q_Paint_Event'Class);

   procedure Emit_Angle_Changed
    (Self      : not null access Cannon_Field'Class;
     New_Angle : Integer);

end Cannon_Fields;
with Cannon_Fields.Moc;
pragma Unreferenced (Cannon_Fields.Moc);

separate (Cannon_Fields)
procedure Emit_Angle_Changed
 (Self : not null access Cannon_Field'Class;
  New_Angle : Integer)
is
begin
   null;
end Emit_Angle_Changed;

package Cannon_Fields.Moc is

end Cannon_Fields.Moc;

package Paint_Events is

   type Q_Paint_Event is limited interface;

end Paint_Events;

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

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

	* sem_ch10.adb (Install_Context): If the unit is a package body,
	install the private with_clauses of the corresponding package
	declaration.

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]