From patchwork Tue Dec 20 14:01:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 132426 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 96776B7030 for ; Wed, 21 Dec 2011 01:01:43 +1100 (EST) Received: (qmail 12970 invoked by alias); 20 Dec 2011 14:01:38 -0000 Received: (qmail 12943 invoked by uid 22791); 20 Dec 2011 14:01:37 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 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; Tue, 20 Dec 2011 14:01:24 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D77582BB00B; Tue, 20 Dec 2011 09:01:20 -0500 (EST) 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 6aQKsod8FQw6; Tue, 20 Dec 2011 09:01:20 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id C226A2BB1AF; Tue, 20 Dec 2011 09:01:20 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id C0D343FEE8; Tue, 20 Dec 2011 09:01:20 -0500 (EST) Date: Tue, 20 Dec 2011 09:01:20 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Hristian Kirtchev Subject: [Ada] Attribute 'Width and pragma Discard_Names Message-ID: <20111220140120.GA28854@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 This patch corrects the expansion of attribute 'Width when applied to a dynamic enumeration type with suppressed names. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-12-20 Hristian Kirtchev * exp_imgv.adb (Expand_Width_Attribute): Add a type conversion from the enumeration subtype to its base subtype. Index: exp_imgv.adb =================================================================== --- exp_imgv.adb (revision 182532) +++ exp_imgv.adb (working copy) @@ -1177,7 +1177,7 @@ -- ... -- else n)))... - -- where n is equal to Rtyp'Pos (Rtyp'Last) + 1 + -- where n is equal to Rtyp'Pos (Ptyp'Last) + 1 -- Note: The above processing is in accordance with the intent of -- the RM, which is that Width should be related to the impl-defined @@ -1206,12 +1206,13 @@ New_Occurrence_Of (Standard_Integer, Loc), Expression => Make_Attribute_Reference (Loc, - Prefix => New_Occurrence_Of (Rtyp, Loc), - Attribute_Name => Name_Pos, - Expressions => New_List ( - Make_Attribute_Reference (Loc, - Prefix => New_Occurrence_Of (Ptyp, Loc), - Attribute_Name => Name_Last))))); + Prefix => New_Occurrence_Of (Rtyp, Loc), + Attribute_Name => Name_Pos, + Expressions => New_List ( + Convert_To (Rtyp, + Make_Attribute_Reference (Loc, + Prefix => New_Occurrence_Of (Ptyp, Loc), + Attribute_Name => Name_Last)))))); -- OK, now we need to build the conditional expression. First -- get the value of M, the largest possible value needed.