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] AI-240


Tested on i686-linux, committed on trunk

The rule in RM95-E.2.3(14/1) permits a formal parameter of an RCI
subprogram to be limited if the limited type has user-specified
Read and Write attributes. However, such parameters were being rejected
when the full type was a private type (such as System.Address) or
was a scalar type. The fix is to test for those stream attributes on
the underlying type as well as the partial view. In Ada 2005 (as per
AI-240), a limited type must have visible attribute specifications of
its Read and Write attributes, so the attributes cannot be specified
in the private part as they can in Ada 95. So additional tests are
added to check that the attributes are visible when compiling with
-gnat05 (and the underlying type is not checked in that case).
--
The following test must compile quietly with -gnat95 and issue an
error when compiled with -gnat05
Compiler commands:
gcc -c -gnat95 other_pkg.adb
gcc -c -gnat05 other_pkg.adb
--
with System;
with Ada.Streams;
package Root is
   pragma Remote_Types;
   type Root_Type is limited private;
private
   type Root_Type is new System.Address;
   procedure Write_Root
      (Stream   : access Ada.Streams.Root_Stream_Type'Class;
       The_Root : in     Root_Type);
   procedure Read_Root
      (Stream   : access Ada.Streams.Root_Stream_Type'Class;
       The_Root :    out Root_Type);
   for Root_Type'Write use Write_Root;
   for Root_Type'Read  use Read_Root;
end Root;
package body Root is
   procedure Write_Root
   -- This subprogram performs data marshalling.
      (Stream   : access Ada.Streams.Root_Stream_Type'Class;
       The_Root : in     Root_Type) is
   begin  -- Write_Root
      null;  -- Dummy function implementation.
   end Write_Root;
   procedure Read_Root
   -- This subprogram performs data unmarshalling.
      (Stream   : access Ada.Streams.Root_Stream_Type'Class;
       The_Root :    out Root_Type) is
   begin  -- Read_Root
      -- Dummy function implementation.
      The_Root := Root_Type(System.Null_Address);
   end Read_Root;
end Root;
with Root;
package Other_Pkg is
   pragma Remote_Call_Interface;
   procedure Do_Stuff (The_Root : in     Root.Root_Type);
private
end Other_Pkg;
package body Other_Pkg is
   procedure Do_Stuff (The_Root : in     Root.Root_Type) is
   begin  -- Do_Stuff
      null;
   end Do_Stuff;
end Other_Pkg;

2005-12-05  Gary Dismukes  <dismukes@adacore.com>

	* sem_cat.adb (Validate_RCI_Subprogram_Declaration): Revise test for
	available user-specified stream attributes on limited parameters to
	also test the type directly rather than only its underlying type (for
	Ada 95) and, in the case of Ada 2005, to check that the user-specified
	attributes are visible at the point of the subprogram declaration.
	For Ada 2005, the error message is modified to indicate that the
	type's stream attributes must be visible (again, only for -gnat05).

Attachment: difs.20
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]