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] Name resolution for limited views


This patch corrects the handling of limited views associated with subprogram
formals of anonymous access type.

   package P is
      type Some_Type ...
   end P;

   limited with P;
   package Main is
      procedure Do_Something (Param : access P.Some_Type);
   end Main;

   with P;
   package Main is
      procedure Do_Something (Param : access P.Some_Type) is ...
   end Main;

If the body of Do_Something references Param in any way, its uses were flagged
as "illegal use of incomplete type" even though this is legal code. When the
limited context of P is uninstalled at the end of Main's spec, the anonymous
access type of Param still references the shadow entity for Some_Type. Later,
when the body of Do_Something is processed and the non-limited view of Some_
Type is available, the compiler would still use the type of Param coming from
the spec of Do_Something. Since this is a general mechanism in the compiler,
the patch adds code to recognize such legal uses of limited views associated
with anonymous access types and prevent false positives.

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

2009-06-23  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_attr.adb: Add with and use clauses for Sem_Ch10.
	(Check_Not_Incomplete_Type): Minor reformatting. Retrieve the root type
	when dealing with class-wide types. Detect a legal shadow entity and
	retrieve its non-limited view.

	* sem_ch10.adb (Has_With_Clause): Move the spec and body of the
	subprogram to top package level from Intall_Limited_Withed_Unit.
	(Install_Limited_Withed_Unit): Remove spec and body of Has_With_Clause.
	Add check which prevents the installation of a limited view if the
	non-limited view is already visible through a with clause.
	(Is_Legal_Shadow_Entity_In_Body): New routine. Detect a residual, but
	legal shadow entity which may occur in subprogram formals of anonymous
	access type.

	* sem_ch10.ads (Is_Legal_Shadow_Entity_In_Body): New routine.

	* sem_ch3.adb (Access_Definition): Remove the propagation of flag
	From_With_Type from the designated type to the generated anonymous
	access type. Remove associated comment.

	* sem_res.adb Add with and use clauses for Sem_Ch10.
	(Full_Designated_Type): Detect a legal shadow entity and retrieve its
	non-limited view. Since the shadow entity may replace a regular
	incomplete type, return the available full view.

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]