From patchwork Fri Sep 8 10:08:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 811461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461717-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="p9oRwX7q"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpY243s20z9rxj for ; Fri, 8 Sep 2017 20:09:00 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=WV4xaD2mEtTUC4GqFDC43QA65IEIr/W+ykrY7ht4sHtQtvKQ9s IuL79G+cnVGEGW8tgs6QXonHGCwCoVOekE+jHwvXY4lgBFiUJT6v6I2Jx/eiYKwU bs+PUxgmpfDAI9Y1rncN3NkUwvCIdUN8umUtK16T6gKd8e3SYRGJlLOP0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=7lNot40AxnbAHi5lbGKX7VXTU7o=; b=p9oRwX7qy6jOHVYCwA0q yPtrySZW+X+vi1Spb4EAh9dt4eGIPB/moZdK9NJ+5qbRYEiws9H+KUPdE3+Ht2na l1NYGJGRxDqRYmaJvgBbcA53318Vz4QR2NBkDZQUf2HzgDHv68Kv1bGOVdBENbIT dXOd+94diAdL1akboXcauZw= Received: (qmail 3111 invoked by alias); 8 Sep 2017 10:08:51 -0000 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 Received: (qmail 2692 invoked by uid 89); 8 Sep 2017 10:08:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Pin, reserved X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Sep 2017 10:08:44 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D0C4E5625F; Fri, 8 Sep 2017 06:08:42 -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 9iftSh-aJrZY; Fri, 8 Sep 2017 06:08:42 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id BF8CE5619D; Fri, 8 Sep 2017 06:08:42 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id BE9A8505; Fri, 8 Sep 2017 06:08:42 -0400 (EDT) Date: Fri, 8 Sep 2017 06:08:42 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Copy representation aspects from type to constrained subtype Message-ID: <20170908100842.GA138795@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This change ensures that the representation aspects Atomic, Independent and Volatile_Full_Access are copied from the base type to the subtype when it is declared with an explicit constraint. For the following package: package P is type Bit is mod 2**1 with Size => 1; type UInt2 is mod 2**2 with Size => 2; type UInt22 is mod 2**22 with Size => 22; type MODE_ENUM is ( Function_0_Default, Function_1, Function_2, Function_3, Function_4, Function_5, Function_6, Function_7) with Size => 3; type EPD_ENUM is ( Disable_Pull_Down, Enable_Pull_Down) with Size => 1; type EPUN_ENUM is ( Enable_Pull_Up, Disable_Pull_Up) with Size => 1; type EHS_ENUM is ( Slow_Low_Noise_With, Fast_Medium_Noise_W) with Size => 1; type EZI_ENUM is ( Disable_Input_Buffer, Enable_Input_Buffer) with Size => 1; type ZIF_ENUM is ( Enable_Input_Glitch, Disable_Input_Glitch) with Size => 1; type EHD_ENUM is ( Normal_Drive_4_Ma_D, Medium_Drive_8_Ma_D, High_Drive_14_Ma_Dr, Ultra_High_Drive_20) with Size => 2; type Pin_Type is (Normal_Drive, High_Drive, High_Speed); type SFS_Register(Pin : Pin_Type := Normal_Drive) is record MODE : MODE_ENUM; EPD : EPD_ENUM; EPUN : EPUN_ENUM; EZI : EZI_ENUM; ZIF : ZIF_ENUM; RESERVED : UInt22; case Pin is when Normal_Drive => ND_EHS_RESERVED : Bit; ND_EHD_RESERVED : UInt2; when High_Drive => EHD : EHD_ENUM; HD_EHS_RESERVED : Bit; when High_Speed => EHS : EHS_ENUM; HS_EHD_RESERVED : UInt2; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access; for SFS_Register use record MODE at 0 range 0 .. 2; EPD at 0 range 3 .. 3; EPUN at 0 range 4 .. 4; ND_EHS_RESERVED at 0 range 5 .. 5; HD_EHS_RESERVED at 0 range 5 .. 5; EHS at 0 range 5 .. 5; EZI at 0 range 6 .. 6; ZIF at 0 range 7 .. 7; ND_EHD_RESERVED at 0 range 8 .. 9; EHD at 0 range 8 .. 9; HS_EHD_RESERVED at 0 range 8 .. 9; RESERVED at 0 range 10 .. 31; end record; type Arr is array (Integer range <>) of SFS_Register(Normal_Drive); end P; the components of the Arr type must inherit the Volatile_Full_Access aspect. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Eric Botcazou * sem_util.ads (Set_Rep_Info): New inline procedure. * sem_util.adb (Set_Rep_Info): Implement it. * sem_ch3.adb (Process_Subtype): If the case of a constraint present, always copy the representation aspects onto the subtype. Index: sem_ch3.adb =================================================================== --- sem_ch3.adb (revision 251877) +++ sem_ch3.adb (working copy) @@ -21556,9 +21556,11 @@ Error_Msg_N ("invalid subtype mark in subtype indication", S); end case; - -- Size and Convention are always inherited from the base type + -- Size, Alignment, Representation aspects and Convention are always + -- inherited from the base type. Set_Size_Info (Def_Id, (Subtype_Mark_Id)); + Set_Rep_Info (Def_Id, (Subtype_Mark_Id)); Set_Convention (Def_Id, Convention (Subtype_Mark_Id)); return Def_Id; Index: sem_util.adb =================================================================== --- sem_util.adb (revision 251880) +++ sem_util.adb (working copy) @@ -21659,6 +21659,20 @@ end if; end Set_Referenced_Modified; + ------------------ + -- Set_Rep_Info -- + ------------------ + + procedure Set_Rep_Info (T1, T2 : Entity_Id) is + begin + Set_Is_Atomic (T1, Is_Atomic (T2)); + Set_Is_Independent (T1, Is_Independent (T2)); + Set_Is_Volatile_Full_Access (T1, Is_Volatile_Full_Access (T2)); + if Is_Base_Type (T1) then + Set_Is_Volatile (T1, Is_Volatile (T2)); + end if; + end Set_Rep_Info; + ---------------------------- -- Set_Scope_Is_Transient -- ---------------------------- Index: sem_util.ads =================================================================== --- sem_util.ads (revision 251875) +++ sem_util.ads (working copy) @@ -2473,6 +2473,12 @@ -- (Referenced_As_LHS if Out_Param is False, Referenced_As_Out_Parameter -- if Out_Param is True) is set True, and the other flag set False. + procedure Set_Rep_Info (T1, T2 : Entity_Id); + pragma Inline (Set_Rep_Info); + -- Copies the Is_Atomic, Is_Independent and Is_Volatile_Full_Access flags + -- from sub(type) entity T2 to (sub)type entity T1, as well as Is_Volatile + -- if T1 is a base type. + procedure Set_Scope_Is_Transient (V : Boolean := True); -- Set the flag Is_Transient of the current scope