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] Build-in place calls with inherited operations of untagged types


When a call invokes an inherited operation, the parent function is placed
on the tree after expansion. If the call is for a build-in-place function,
subsequent expansion builds an access type to designate the constructed
object. The designated type of this access type is the type imposed by the
context, rather than that of the function, which may be the parent operation.
The following must compile quietly in Ada05:

procedure Limited_Problem is

   package Isolated is

      type Limited_Type is limited record
         Value : Integer:= -12345;
      end record;

      function Create return Limited_Type;

   end Isolated;

   package body Isolated is

      function Create return Limited_Type is
      begin
         return (others => <>);
      end Create;

   end Isolated;

   type Limited_Type_2 is new Isolated.Limited_Type;

   X : Limited_Type_2 := Create;

begin
   null;
end Limited_Problem;

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

2010-06-17  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch6.adb (Make_Build_In_Place_Call_In_Object_Declaration): The
	designated type of the generated pointer is the type of the original
	expression, not that of the function call itself, because the return
	type may be an untagged  derived type and the function may be an
	inherited operation.

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]