From patchwork Mon Apr 30 08:05:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 155808 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 8A9BDB6F9A for ; Mon, 30 Apr 2012 18:12:56 +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=1336378376; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:User-Agent:MIME-Version: Content-Type:Message-Id:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=/Izoll/+Shp1lFTVFeOv4Rfk5rk=; b=mFhASKYx+Ebyfrg eFFSo4xlq/DcpbMBIG/NdM7ZHynD7bjd6uWIAnqezEbgX/22jRScuiwHVxuJ+AbI /e8AGzx/bZ+H3YgA1uhbNVUF328Jx5LdgccoUsb5fZWrLPH5Nj6hO0Mz+KYySqEm KUX3zh2/9rdmYDDqJ9o6S2XP/XQE= 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:User-Agent:MIME-Version:Content-Type:Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Yy7olrQopDn/x47nBCImJTH2IhW6j8S5ugChPSKwuaFnf2ms/7naoHTd+oSCns VBnDYw4JcfpnpGp7ZF7DBcBUkJ1vE95xzHIhj/9qnjOpjSV0GTAtkoCzpczV9Yri 1q0B7KI1sSPSj5wN5YIFh309uJnCMKheyGuEHIIsRWsWI=; Received: (qmail 15193 invoked by alias); 30 Apr 2012 08:12:52 -0000 Received: (qmail 15181 invoked by uid 22791); 30 Apr 2012 08:12:51 -0000 X-SWARE-Spam-Status: No, hits=-2.0 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; Mon, 30 Apr 2012 08:12:38 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9BC2529000D for ; Mon, 30 Apr 2012 10:12:43 +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 jOL0MebKez2I for ; Mon, 30 Apr 2012 10:12:43 +0200 (CEST) Received: from [192.168.1.2] (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 640E0290001 for ; Mon, 30 Apr 2012 10:12:43 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix fallout of bitfields ABI change on Windows Date: Mon, 30 Apr 2012 10:05:36 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201204301005.36732.ebotcazou@adacore.com> 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 The MS bitfields ABI and its stringent rules totally break packing in Ada, so we cannot use the C layout in this case. The i386.c hunk fixes an oversight which would result in gazillions of warnings for QUAL_UNION_TYPE. Tested on i586-suse-linux and i686-pc-mingw32, applied on the mainline and the 4.7 branch (as obvious for the i386.c hunk). 2012-04-30 Eric Botcazou * config/i386/i386.c (ix86_handle_struct_attribute): Use the proper predicate to discriminate types. 2012-04-30 Eric Botcazou * gcc-interface/utils.c (finish_record_type): Force the traditional GCC layout for bitfields on the type if it is packed or has a representation clause and an alternate layout is available. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 186907) +++ config/i386/i386.c (working copy) @@ -32465,8 +32465,7 @@ ix86_handle_struct_attribute (tree *node else type = node; - if (!(type && (TREE_CODE (*type) == RECORD_TYPE - || TREE_CODE (*type) == UNION_TYPE))) + if (!(type && RECORD_OR_UNION_TYPE_P (*type))) { warning (OPT_Wattributes, "%qE attribute ignored", name); Index: ada/gcc-interface/utils.c =================================================================== --- ada/gcc-interface/utils.c (revision 186956) +++ ada/gcc-interface/utils.c (working copy) @@ -721,6 +721,19 @@ finish_record_type (tree record_type, tr case where there is a rep clause but all fields have errors and no longer have a position. */ TYPE_SIZE (record_type) = 0; + + /* Ensure we use the traditional GCC layout for bitfields when we need + to pack the record type or have a representation clause. The other + possible layout (Microsoft C compiler), if available, would prevent + efficient packing in almost all cases. */ +#ifdef TARGET_MS_BITFIELD_LAYOUT + if (TARGET_MS_BITFIELD_LAYOUT && TYPE_PACKED (record_type)) + decl_attributes (&record_type, + tree_cons (get_identifier ("gcc_struct"), + NULL_TREE, NULL_TREE), + ATTR_FLAG_TYPE_IN_PLACE); +#endif + layout_type (record_type); }