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] Avoid spurious error reported by the compiler


This patch modifies the approach taken by the compiler to save/restore
the scope stack. The save routine now returns the list of entitites
which have been temporarily removed from visibility, and that list
is passed to the restore routine to restore their visibility.

This approach consumes more memory than the previous approach
but avoids latent problems caused by the previous approach.

After this patch the following test compiles silently.

package P is
   type Root_Type is abstract tagged limited record
      N : Natural;
   end record;

   type Child_Type is abstract limited new Root_Type with null record;
   type Interface_Type is limited interface;
   function F (N : Natural) return Interface_Type is abstract;
end P;

generic package P.Generic_Child_Package is
   type T is new P.Child_Type and P.Interface_Type with null record;
   overriding function F (N : in Natural) return T;
end P.Generic_Child_Package;

with P.Generic_Child_Package;
package Q is
   package Instance_Package is new P.Generic_Child_Package;

   X : Instance_Package.T := Instance_Package.F (10);
end Q;

Command: gcc -c -gnat05 q.ads

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

2013-07-08  Javier Miranda  <miranda@adacore.com>

	* sem_ch8.ad[sb] (Save_Scope_Stack): Modified to return the list
	of entities which have been temporarily removed from immediate
	visibility.
	(Restore_Scope_Stack): Modified to receive an
	additional parameter with the list of entities whose immediate
	visibility must be restored.
	* sem.adb (Do_Analyze): Use new version of
	Save_Scope_Stack/Restore_Scope_Stack
	* sem_ch12.adb (Inline_Instance_Body): Use new version of
	Save_Scope_Stack and Restore_Scope_Stack

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]