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] Visiblity of formals of formal packages in an instance


This patch fixes a visibility problem in the presence of formal packages that
have themselves formal packages declared with a box.  In a generic unit the
formals of such packages are visible, and this visibility must be properly
reflected when compiling an instance. 

The following must compile quietly:

   gcc -c -gnat05 test_extensions.adb

---
with Ada.Numerics.Generic_Real_Arrays;
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Arrays;
with Whatever;
procedure Test_Extensions is

   package Real_Arrays
   is new Ada.Numerics.Generic_Real_Arrays (Float);
   package Complex_Types
   is new Ada.Numerics.Generic_Complex_Types (Float);
   package Complex_Arrays
   is new Ada.Numerics.Generic_Complex_Arrays (Real_Arrays, Complex_Types);

   package Extensions
   is new Whatever (Complex_Arrays);

begin
   null;
end Test_Extensions;
---
with Ada.Numerics.Generic_Complex_Arrays;
generic
   with package Complex_Arrays is new Ada.Numerics.Generic_Complex_Arrays (<>);
package Whatever is
   pragma Elaborate_Body;
   use Complex_Arrays;
   use Complex_Arrays.Complex_Types;
   use Complex_Arrays.Real_Arrays;
end Whatever;
---
pragma Warnings (Off);
with System.Generic_Array_Operations;
pragma Warnings (On);

package body Whatever is
   procedure Transpose_Which_Doesnt_Instantiate
   is new System.Generic_Array_Operations.Transpose
     (Scalar => Real'Base,
      Matrix => Real_Matrix);

   procedure Transpose_Which_Instantiates
   is new System.Generic_Array_Operations.Transpose
     (Scalar => Real_Arrays.Real'Base,
      Matrix => Real_Matrix);
end Whatever;

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

2014-01-22  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch8.adb (From_Actual_Package): Introduce a recursive
	sub-procedure Declared_In_Actual to handle properly the visibility
	of actuals in actual packages, that are themselves actuals to a
	actual package of the current instance. This mimics properly the
	visibility of formals of formal packages declared with a box,
	within the corresponding generic unit.

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]