From patchwork Thu Apr 26 09:46:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 155213 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 C894AB6FA5 for ; Thu, 26 Apr 2012 19:46:49 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1336038411; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=Qg83C7zcSpHu9HSwc+B2 wL5Fz1Y=; b=NJ+sYwDfGYbnkaUv1q714L23JIvVRIUIaXXokvU0RJmNyRuK3dii 5QxRKpiuOY/YNSNhx6XpOuosZX8kn14KfHyE8HGvGx6qj4WnacHIssR1+ZC2seD3 MmvtoKTrAYtn8HT+r16m2Rf5eHJLYAvfCCUfyTZOwcHICc6eN6RpEms= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=PV0D4qHYIPMM4Wkg8hV6IGx1ygoOvRwQ083o/kzyUaoZXzIt6NhpBkNDcBKNn8 tUXv+gOfrDG806ZBvLtqHNDCa5ZoN4Mib5fqoSjieRZ4Hx4+OtngyP2Hv7TXz/SE rbe//vXr10keqxLTmJuLD7re+XDCdcFcQh6TCmxD8RYPs=; Received: (qmail 17407 invoked by alias); 26 Apr 2012 09:46:44 -0000 Received: (qmail 17397 invoked by uid 22791); 26 Apr 2012 09:46:43 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL 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; Thu, 26 Apr 2012 09:46:26 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5EDA01C6EFF; Thu, 26 Apr 2012 05:46:25 -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 u4K-dg0mpCOE; Thu, 26 Apr 2012 05:46:25 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 37BC71C6EFA; Thu, 26 Apr 2012 05:46:25 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 371753FEE8; Thu, 26 Apr 2012 05:46:25 -0400 (EDT) Date: Thu, 26 Apr 2012 05:46:25 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [Ada] Wrong size for variant records with single variant with front-end layout Message-ID: <20120426094625.GA3907@adacore.com> MIME-Version: 1.0 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org When front-end layout is enabled (such as for non-GCC targets like AAMP), the RM_Size value of variant records with a static-sized single variant is computed incorrectly as storage units rather than bits (which can cause incorrect code for reading and writing objects). This case is now tested for and RM_Size is properly determined as a bit size. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-04-26 Gary Dismukes * layout.adb (Layout_Component_List): Test for the case of a single variant and the size of its component list was computed as an integer literal, and use that size (which is in bits) as is rather than converting to storage units. Index: layout.adb =================================================================== --- layout.adb (revision 186860) +++ layout.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -2135,8 +2135,19 @@ -- others case. if No (RM_Siz_Expr) then - RM_Siz_Expr := Bits_To_SU (RM_SizV); + -- If this is the only variant and the size is a + -- literal, then use bit size as is, otherwise convert + -- to storage units and continue to the next variant. + + if No (Prev (Var)) + and then Nkind (RM_SizV) = N_Integer_Literal + then + RM_Siz_Expr := RM_SizV; + else + RM_Siz_Expr := Bits_To_SU (RM_SizV); + end if; + -- Otherwise construct the appropriate test else