From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24391 invoked by alias); 14 Oct 2011 15:05:52 -0000 Received: (qmail 24380 invoked by uid 22791); 14 Oct 2011 15:05:50 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Oct 2011 15:05:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 358A22BB0FA; Fri, 14 Oct 2011 11:05:32 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Umq5dNOxzJWz; Fri, 14 Oct 2011 11:05:32 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 1B9152BB082; Fri, 14 Oct 2011 11:05:32 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 15F8292BF6; Fri, 14 Oct 2011 11:05:32 -0400 (EDT) Date: Fri, 14 Oct 2011 15:22:00 -0000 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Aliasing and objects in extended return statements Message-ID: <20111014150532.GA14721@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cNdxnHkX5QqsyA0e" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg01292.txt.bz2 --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1328 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 * 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. --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=difs Content-length: 654 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); --cNdxnHkX5QqsyA0e--