From patchwork Sun Jan 6 11:56:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 209745 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 A08CD2C007E for ; Sun, 6 Jan 2013 23:05:00 +1100 (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=1358078701; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=+J9ISmdiE8Xs+vFPtoY89MOXFss=; b=vtqcocEd1nK5G+c J/NiidtLRRzAjfhCYtFvDK5VWze+1Imbqpc29xeCIkScGPeL6pAMqF39v5B6DT/c 5bGYtPPGJlez6Vz9q9c5qNnT1PftBGOo/AZ/OAfbaSJOmxqBN2N6QYDU7UrVeHRg UeAOK/4vOTVy9Wxna556pOuQLeGs= 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:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=cuBb0fB894agyM01vSzNMbpSw53oIS1/LThSP7srKPncfq0INfdSOFVhmBdeNE ntPgnuSX1nzrw5JEMFKB9F6ViolGcHRuknbJebaaXKGYMysH6cjE5Cy8w7IJYPZH VZZAhXgq/d0iiWgz1tmUtN4CxaiVbEr3iqYJdjdbvY+l4=; Received: (qmail 25165 invoked by alias); 6 Jan 2013 12:04:53 -0000 Received: (qmail 25156 invoked by uid 22791); 6 Jan 2013 12:04:51 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 Jan 2013 12:04:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9A086290031 for ; Sun, 6 Jan 2013 13:04:54 +0100 (CET) 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 vY6dogc-pOV3 for ; Sun, 6 Jan 2013 13:04:54 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 61A4B29002B for ; Sun, 6 Jan 2013 13:04:54 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix layout of misaligned integer subtypes on big-endian Date: Sun, 06 Jan 2013 12:56:41 +0100 Message-ID: <1977384.cmRLxvxfV8@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.16-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 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 This is a regression present on mainline and 4.7 branch, exposed by a recent change in the propagation of alignment from types to subtypes. The layout of misaligned integer subtypes is incorrect on big-endian platforms (it is left justified instead of being right justified). Fixed thusly, tested on x86_64-suse-linux, applied on mainline and 4.7 branch. 2013-01-06 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Do not pack the field of the record type made for a misaligned type. 2013-01-06 Eric Botcazou * gnat.dg/alignment10.adb: New test. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 194939) +++ gcc-interface/decl.c (working copy) @@ -1887,8 +1887,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entit } /* If the type we are dealing with has got a smaller alignment than the - natural one, we need to wrap it up in a record type and under-align - the latter. We reuse the padding machinery for this purpose. */ + natural one, we need to wrap it up in a record type and misalign the + latter; we reuse the padding machinery for this purpose. Note that, + even if the record type is marked as packed because of misalignment, + we don't pack the field so as to give it the size of the type. */ else if (align > 0) { tree gnu_field_type, gnu_field; @@ -1918,7 +1920,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entit a bitfield. */ gnu_field = create_field_decl (get_identifier ("F"), gnu_field_type, - gnu_type, NULL_TREE, bitsize_zero_node, 1, 0); + gnu_type, TYPE_SIZE (gnu_field_type), + bitsize_zero_node, 0, 0); finish_record_type (gnu_type, gnu_field, 2, debug_info_p); compute_record_mode (gnu_type);