From patchwork Thu Oct 7 13:06:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 67055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id CCEF2B6EF7 for ; Fri, 8 Oct 2010 00:07:11 +1100 (EST) Received: (qmail 13428 invoked by alias); 7 Oct 2010 13:07:01 -0000 Received: (qmail 13259 invoked by uid 22791); 7 Oct 2010 13:06:58 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Oct 2010 13:06:52 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B1F07CB0223; Thu, 7 Oct 2010 15:06:50 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xiA2RbU+6Vk4; Thu, 7 Oct 2010 15:06:50 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id A0BE2CB01D4; Thu, 7 Oct 2010 15:06:50 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 9E743D9BB5; Thu, 7 Oct 2010 15:06:48 +0200 (CEST) Date: Thu, 7 Oct 2010 15:06:48 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Aggregate for records with components of an anonymous access type Message-ID: <20101007130648.GA14808@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org In Ada2012, a choice list in an aggregate can include several components of anonymous access types, as long as their designated subtypes match. The following must compile quietly in Ada2012 mode: procedure Record_Aggregate is type List_Element1 is record Data : Integer; Prev, Next : access List_Element1; end record; type List_Element2; type List_Element2_Access is access all List_Element2; type List_Element2 is record Data : Integer; Prev, Next : List_Element2_Access; end record; Obj1 : List_Element1; Obj2 : List_Element2; begin Obj2 := (Data => -1, Prev | Next => null); Obj1 := (Data => -1, Prev | Next => null); Obj1 := (Data => 3, Prev | Next => new List_Element1); end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-07 Ed Schonberg * sem_aggr.adb (Analyze_Record_Aggregate): In Ada2012, a choice list in a record aggregate can correspond to several components of anonymous access types, as long as the designated subtypes match. Index: sem_aggr.adb =================================================================== --- sem_aggr.adb (revision 165080) +++ sem_aggr.adb (working copy) @@ -3890,8 +3890,23 @@ package body Sem_Aggr is elsif No (Typech) then Typech := Base_Type (Etype (Component)); + -- AI05-0199: In Ada2012, several components of anonymous + -- access types can appear in a choice list, as long as the + -- designated types match. + elsif Typech /= Base_Type (Etype (Component)) then - if not Box_Present (Parent (Selectr)) then + if Ada_Version >= Ada_12 + and then Ekind (Typech) = E_Anonymous_Access_Type + and then + Ekind (Etype (Component)) = E_Anonymous_Access_Type + and then Base_Type (Designated_Type (Typech)) = + Base_Type (Designated_Type (Etype (Component))) + and then + Subtypes_Statically_Match (Typech, (Etype (Component))) + then + null; + + elsif not Box_Present (Parent (Selectr)) then Error_Msg_N ("components in choice list must have same type", Selectr);