From patchwork Mon Jun 11 07:58:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 164091 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 728FCB6FF5 for ; Mon, 11 Jun 2012 18:03:20 +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=1340006603; 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=DRYDvLQFBG3M98Vp+EB4Ei2D6kA=; b=HDjvCQHxptfKNpc 8mA++d+yi7lhHjaLufm6Funh69Tm2LjkR2CVzLQRPtC0XtBicESgep2ONHI/CTaz 4Fz2rheUu/bFJG7CY3w3zjnvEu7eWFHH9PGsNAFZL9Gjbh82RIpaFEMtoyJiDcSu 4KpDZODmTQreqYBKt0yJ59cWRCpU= 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=qPTtn+Yz4qs6A753J4Yk4FGwbiffH5lPrRUXWnBE/1wtKcScLuIfrV6TKU9kNA IKpXsNhCdOKPDfVyhfwl8JcMeKLumrFg3P6wXNIuqkCEHj9ODFN2KJSni2HdCoTT ApJSo3z+aoWhS2Y99Z91yqzKhO69wr6+9uqz/azBoCkQM=; Received: (qmail 31064 invoked by alias); 11 Jun 2012 08:03:10 -0000 Received: (qmail 31049 invoked by uid 22791); 11 Jun 2012 08:03:07 -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) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jun 2012 08:02:45 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4867D290051 for ; Mon, 11 Jun 2012 10:02:49 +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 Ar-p0tc+tte9 for ; Mon, 11 Jun 2012 10:02:49 +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 019CD29003A for ; Mon, 11 Jun 2012 10:02:49 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Adjust Esize processing in gigi Date: Mon, 11 Jun 2012 09:58:23 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201206110958.23264.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 This makes it so that the size of types (Esize) is retrieved early and properly capped for elementary types, in order to avoid obscure failures later on for huge sizes. Nothing is changed for composite types. Tested on i586-suse-linux, applied on the mainline. 2012-06-11 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity): Translate the Esize on entry only for elementary types and abort if it is too large. : Make sure the Esize is known before using it. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 188377) +++ gcc-interface/decl.c (working copy) @@ -377,11 +377,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entit prepend_attributes (First_Subtype (Base_Type (gnat_entity)), &attr_list); - /* Compute a default value for the size of the type. */ - if (Known_Esize (gnat_entity) - && UI_Is_In_Int_Range (Esize (gnat_entity))) + /* Compute a default value for the size of an elementary type. */ + if (Known_Esize (gnat_entity) && Is_Elementary_Type (gnat_entity)) { unsigned int max_esize; + + gcc_assert (UI_Is_In_Int_Range (Esize (gnat_entity))); esize = UI_To_Int (Esize (gnat_entity)); if (IN (kind, Float_Kind)) @@ -2948,14 +2949,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entit if (Known_Alignment (gnat_entity)) TYPE_ALIGN (gnu_type) = validate_alignment (Alignment (gnat_entity), gnat_entity, 0); - else if (Is_Atomic (gnat_entity)) - TYPE_ALIGN (gnu_type) - = esize >= BITS_PER_WORD ? BITS_PER_WORD : ceil_pow2 (esize); + else if (Is_Atomic (gnat_entity) && Known_Esize (gnat_entity)) + { + unsigned int size = UI_To_Int (Esize (gnat_entity)); + TYPE_ALIGN (gnu_type) + = size >= BITS_PER_WORD ? BITS_PER_WORD : ceil_pow2 (size); + } /* If a type needs strict alignment, the minimum size will be the type size instead of the RM size (see validate_size). Cap the alignment, lest it causes this type size to become too large. */ - else if (Strict_Alignment (gnat_entity) - && Known_RM_Size (gnat_entity)) + else if (Strict_Alignment (gnat_entity) && Known_RM_Size (gnat_entity)) { unsigned int raw_size = UI_To_Int (RM_Size (gnat_entity)); unsigned int raw_align = raw_size & -raw_size;