From patchwork Wed Aug 31 09:33:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 112487 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 E4477B6F80 for ; Wed, 31 Aug 2011 19:34:54 +1000 (EST) Received: (qmail 14302 invoked by alias); 31 Aug 2011 09:34:31 -0000 Received: (qmail 13921 invoked by uid 22791); 31 Aug 2011 09:34:28 -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; Wed, 31 Aug 2011 09:33:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DE8AF2BAB70; Wed, 31 Aug 2011 05:33:58 -0400 (EDT) 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 GJzV16g0WhBN; Wed, 31 Aug 2011 05:33:58 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id B485F2BAB48; Wed, 31 Aug 2011 05:33:58 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id A4F583FEE8; Wed, 31 Aug 2011 05:33:58 -0400 (EDT) Date: Wed, 31 Aug 2011 05:33:58 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Expansion of indexed referenced to packed arrays when prefix is a call Message-ID: <20110831093358.GA19933@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 When an indexed reference to a packed array is expanded, it is rewritten as a boolean operation on the prefix that denotes the packed array. If the prefix is a function call it must not be reanalyzed, because it will have been expanded already. and may carry extra actuals for accessibility checks. No simple example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-31 Ed Schonberg * exp_pakd.adb (Convert_To_PAT_Type): If prefix is a function call, do not reanalyze it. Index: exp_pakd.adb =================================================================== --- exp_pakd.adb (revision 178358) +++ exp_pakd.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -702,7 +702,9 @@ -- see Reset_Packed_Prefix. On the other hand, if the prefix is a simple -- array reference, reanalysis can produce spurious type errors when the -- PAT type is replaced again with the original type of the array. Same - -- for the case of a dereference. The following is correct and minimal, + -- for the case of a dereference. Ditto for function calls: expansion + -- may introduce additional actuals which will trigger errors if call + -- is reanalyzed. The following is correct and minimal, -- but the handling of more complex packed expressions in actuals is -- confused. Probably the problem only remains for actuals in calls. @@ -713,6 +715,7 @@ (Nkind (Aexp) = N_Indexed_Component and then Is_Entity_Name (Prefix (Aexp))) or else Nkind (Aexp) = N_Explicit_Dereference + or else Nkind (Aexp) = N_Function_Call then Set_Analyzed (Aexp); end if;