From patchwork Sat Jul 3 09:49:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 57796 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 732721007D3 for ; Sat, 3 Jul 2010 19:54:57 +1000 (EST) Received: (qmail 28569 invoked by alias); 3 Jul 2010 09:54:55 -0000 Received: (qmail 28561 invoked by uid 22791); 3 Jul 2010 09:54:54 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 03 Jul 2010 09:54:49 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 857A8CB0240 for ; Sat, 3 Jul 2010 11:54:47 +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 ADkCeso8eMnT for ; Sat, 3 Jul 2010 11:54:47 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 5A07CCB01DB for ; Sat, 3 Jul 2010 11:54:47 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Lift unexpected alignment restriction on modular types Date: Sat, 3 Jul 2010 11:49:57 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201007031149.57683.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 Alignment clauses that specify a lower alignment than the natural one are unexpectedly rejected by the compiler. Fixed thusly, tested on i586-suse-linux, applied on the mainline. 2010-07-03 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Branch to common code handling the alignment of discrete types. : Likewise. : Likewise. 2010-07-03 Eric Botcazou * gnat.dg/modular3.adb: New test. * gnat.dg/modular3_pkg.ads: New helper. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 161767) +++ gcc-interface/decl.c (working copy) @@ -1496,7 +1496,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit /* Note that the bounds are updated at the end of this function to avoid an infinite recursion since they refer to the type. */ } - break; + goto discrete_type; case E_Signed_Integer_Type: case E_Ordinary_Fixed_Point_Type: @@ -1504,7 +1504,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit /* For integer types, just make a signed type the appropriate number of bits. */ gnu_type = make_signed_type (esize); - break; + goto discrete_type; case E_Modular_Integer_Type: { @@ -1543,7 +1543,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit gnu_type = gnu_subtype; } } - break; + goto discrete_type; case E_Signed_Integer_Subtype: case E_Enumeration_Subtype: @@ -1632,6 +1632,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entit gnat_to_gnu_type (Original_Array_Type (gnat_entity))); + discrete_type: + /* We have to handle clauses that under-align the type specially. */ if ((Present (Alignment_Clause (gnat_entity)) || (Is_Packed_Array_Type (gnat_entity) @@ -1685,9 +1687,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entit relate_alias_sets (gnu_type, gnu_field_type, ALIAS_SET_COPY); - /* Don't notify the field as "addressable", since we won't be taking - it's address and it would prevent create_field_decl from making a - bitfield. */ + /* Don't declare the field as addressable since we won't be taking + its address and this would prevent create_field_decl from making + a bitfield. */ gnu_field = create_field_decl (get_identifier ("OBJECT"), gnu_field_type, gnu_type, NULL_TREE, bitsize_zero_node, 1, 0); @@ -1736,9 +1738,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entit TYPE_ALIGN (gnu_type) = align; relate_alias_sets (gnu_type, gnu_field_type, ALIAS_SET_COPY); - /* Don't notify the field as "addressable", since we won't be taking - it's address and it would prevent create_field_decl from making a - bitfield. */ + /* Don't declare the field as addressable since we won't be taking + its address and this would prevent create_field_decl from making + a bitfield. */ gnu_field = create_field_decl (get_identifier ("F"), gnu_field_type, gnu_type, NULL_TREE, bitsize_zero_node, 1, 0);