public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Aliasing and objects in extended return statements
@ 2011-10-14 15:22 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2011-10-14 15:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]

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
      record
          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
   begin
      return X : aliased Vector := S'(others => <>); --  ERROR
   end F;

begin
   null;
end Illegal_Alias;

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

2011-10-14  Ed Schonberg  <schonberg@adacore.com>

	* 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 #2: difs --]
[-- Type: text/plain, Size: 654 bytes --]

Index: par-ch6.adb
===================================================================
--- par-ch6.adb	(revision 179984)
+++ par-ch6.adb	(working copy)
@@ -1677,6 +1677,14 @@
          Scan; -- past ALIASED
          Set_Aliased_Present (Decl_Node);
 
+         if Ada_Version < Ada_2012 then
+            Error_Msg_SC -- CODEFIX
+              ("ALIASED not allowed in extended return in Ada2012?");
+         else
+            Error_Msg_SC -- CODEFIX
+              ("ALIASED not allowed in extended return");
+         end if;
+
          if Token = Tok_Constant then
             Scan; -- past CONSTANT
             Set_Constant_Present (Decl_Node);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-10-14 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-14 15:22 [Ada] Aliasing and objects in extended return statements Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).