This is the mail archive of the 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] Aliasing and objects in extended return statements

AI05-0053 forbids the use of the aliased keyword in the object declaration of an
extended return statement. This avoids semantic complications with return
objects that are not of an immutably limited type, and which therefore  are not
necesarily built in place.

Compiling the following in -gnat12 mode must yield:

   illegal_alias.adb:15:26: "aliased" not allowed in extended return

Compiling it in gnat05 mode must yield:

illegal_alias.adb:15:26: warning:
        "aliased" not allowed in extended return in Ada2012

procedure Illegal_Alias is
   type Outer;
   type Inner (Ref : access Outer) is limited null record;
   type Outer is limited
          Self : Inner (Outer'Access);
          Data : Integer := 0;
      end record;

   type Vector is array (Positive range <>) of Outer;
   subtype S is Vector (1 .. 10);

   function F return Vector is
      return X : aliased Vector := S'(others => <>); --  ERROR
   end F;

end Illegal_Alias;

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

2011-10-14  Ed Schonberg  <>

	* par-ch6.adb (P_Return_Object_Declaration): In Ada 2012 mode,
	reject an aliased keyword on the object declaration of an extended
	return statement. In older versions of the language indicate
	that this is illegal in the standard.

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]