From patchwork Fri Sep 8 08:59:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 811391 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-461702-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="xnGbfknn"; 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 3xpWVl03y9z9sBW for ; Fri, 8 Sep 2017 19:00:14 +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=vDdERjcEOqlOfU04sSo/j06agbrBs0fQ2/3LAHz3EaSIDXuuT3 mr8YopZ3o6//0zVkhSHjYpeI/rM89TnqFp3MNHJYzKeBiilAuA/tKFh7o1s0z1Mq WXZbwEig7lEqrgLKGDIkcZe+clYYOleh2KH+E3Ag7QemgjNDYJfCcJ37k= 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=xrpyBJL+8asGyplOdewV0DkaOfo=; b=xnGbfknnSVc6nc8DWzfX yXm3rfbFuGs4J/jn1VlZTfTUAxXEIT4bDnkJVoakcxAisTdAHbi6eZvl4IZOZH36 JfTna8zKFgQBfnZV4SQxHCJ1zIEz35F6r6oyJdM2Uy3x8bKtg7G59yixqk6eaQgf Kd5OUOjsrVQ5FSz32ibMuO8= Received: (qmail 92092 invoked by alias); 8 Sep 2017 08:59:58 -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 91975 invoked by uid 89); 8 Sep 2017 08:59:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= 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 08:59:52 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 068C25619D; Fri, 8 Sep 2017 04:59:51 -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 l8AIhEjjY5Xx; Fri, 8 Sep 2017 04:59:50 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id E7F8A56126; Fri, 8 Sep 2017 04:59:50 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id E6FD8505; Fri, 8 Sep 2017 04:59:50 -0400 (EDT) Date: Fri, 8 Sep 2017 04:59:50 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Small fix for couple of internal glitches with record layout Message-ID: <20170908085950.GA68784@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This change ensures that (1) -gnatR always displays the record layout that was used internally by the compiler for code generation and (2) the record layout is fully adjusted internally when the reverse bit order is specified. No functional changes expected because the first issue was papering over the second issue and the second issue was very likely harmless in practice since the normalized position is redundant with the bit offset, which was correct. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Eric Botcazou * repinfo.adb (List_Record_Info): During first loop, do not override the normalized position and first bit if they have already been set. Move fallback code for the packed case to the case where it belongs. * sem_ch13.adb (Adjust_Record_For_Reverse_Bit_Order): Also adjust the normalized position of components. (Adjust_Record_For_Reverse_Bit_Order_Ada_95): Likewise. Index: repinfo.adb =================================================================== --- repinfo.adb (revision 251863) +++ repinfo.adb (working copy) @@ -894,30 +894,30 @@ Cfbit := Component_Bit_Offset (Comp); if Rep_Not_Constant (Cfbit) then - UI_Image_Length := 2; + -- If the record is not packed, then we know that all fields + -- whose position is not specified have a starting normalized + -- bit position of zero. + if Unknown_Normalized_First_Bit (Comp) + and then not Is_Packed (Ent) + then + Set_Normalized_First_Bit (Comp, Uint_0); + end if; + + UI_Image_Length := 2; -- For "??" marker else -- Complete annotation in case not done - Set_Normalized_Position (Comp, Cfbit / SSU); - Set_Normalized_First_Bit (Comp, Cfbit mod SSU); + if Unknown_Normalized_First_Bit (Comp) then + Set_Normalized_Position (Comp, Cfbit / SSU); + Set_Normalized_First_Bit (Comp, Cfbit mod SSU); + end if; Sunit := Cfbit / SSU; UI_Image (Sunit); end if; - -- If the record is not packed, then we know that all fields - -- whose position is not specified have a starting normalized - -- bit position of zero. - - if Unknown_Normalized_First_Bit (Comp) - and then not Is_Packed (Ent) - then - Set_Normalized_First_Bit (Comp, Uint_0); - end if; - - Max_Suni_Length := - Natural'Max (Max_Suni_Length, UI_Image_Length); + Max_Suni_Length := Natural'Max (Max_Suni_Length, UI_Image_Length); end if; Next_Component_Or_Discriminant (Comp); Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 251866) +++ sem_ch13.adb (working copy) @@ -627,6 +627,7 @@ end if; Set_Component_Bit_Offset (Comp, Pos * SSU + NFB); + Set_Normalized_Position (Comp, Pos + NFB / SSU); Set_Normalized_First_Bit (Comp, NFB mod SSU); end; end loop; @@ -750,6 +751,9 @@ (System_Storage_Unit - 1) - (Start_Bit + CSZ - 1)); + Set_Normalized_Position (Comp, + Component_Bit_Offset (Comp) / System_Storage_Unit); + Set_Normalized_First_Bit (Comp, Component_Bit_Offset (Comp) mod System_Storage_Unit); end if;