From patchwork Fri Jan 4 09:09:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 209405 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 6C9B02C007A for ; Fri, 4 Jan 2013 20:09:14 +1100 (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=1357895355; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=LvwGXIkYfldAMKBU66Hw iSXbpHY=; b=T6K66VvMgI33eWk/b0iHCeYXI52FQ+SnLEtHDdZtMO7EkvRDCgB8 f51aGJiI269drnXWgU/itauhnSBzaDxZ0LiaEfsOOkmqRP8G5LJ59GR3vM4DO5QB 7vSxMRNWAw8g/DdPoMF8XqyQJLTQNSUdGhJSMKK68wNsODD70Fkw8Ug= 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:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=nsA5x/1rgHqz1O+oOpoib1T//yalqJlwHp+Vdt/eeSlYuSdHWZg20C6VdFrlgW tlaMYKM9BE6hb2cp2Anmq5gNxJW2l5YLkVuUKgHhuqNfuy9mb56TNYYFN7CrKBMP kvk8JBGbINAc/nKE9FgO2DJizFlK5Z7J6dDj+CgC9Rtqs=; Received: (qmail 8506 invoked by alias); 4 Jan 2013 09:09:08 -0000 Received: (qmail 8493 invoked by uid 22791); 4 Jan 2013 09:09:07 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO 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; Fri, 04 Jan 2013 09:09:02 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CAB542E518; Fri, 4 Jan 2013 04:09:01 -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 d5bnemMLI9ov; Fri, 4 Jan 2013 04:09:01 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 9F4DE2E36C; Fri, 4 Jan 2013 04:09:01 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 9A68E3FF09; Fri, 4 Jan 2013 04:09:01 -0500 (EST) Date: Fri, 4 Jan 2013 04:09:01 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Hristian Kirtchev Subject: [Ada] Attribute Loop_Entry and index check generation Message-ID: <20130104090901.GA17262@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 delays the generation of index checks for the following cases of Loop_Entry attribute references: Prefix'Loop_Entry (Expr) Prefix'Loop_Entry (Expr1, Expr2, ... ExprN) Even though these constructs appear initially as attribute references, analysis converts them into indexed components to reflect their true semantics. Without this patch, expansion of the indexed components would generate index checks of the following form [constraint_error when not (blah in a'loop_entry'first .. a'loop_entry'last) "index check failed"] and the back end would subsequently fail because it cannot process Loop_Entry. Tested on x86_64-pc-linux-gnu, committed on trunk 2013-01-04 Hristian Kirtchev * checks.adb (Generate_Index_Checks): Delay the generation of the check for an indexed component where the prefix mentions Loop_Entry until the attribute has been properly expanded. * exp_ch5.adb (Expand_Loop_Entry_Attributes): Perform minor decoration of the constant that captures the value of Loop_Entry's prefix at the entry point into a loop. Generate index checks for an attribute reference that has been transformed into an indexed component. Index: exp_ch5.adb =================================================================== --- exp_ch5.adb (revision 194841) +++ exp_ch5.adb (working copy) @@ -1828,11 +1828,29 @@ Object_Definition => New_Reference_To (Typ, Loc), Expression => Relocate_Node (Prefix (LE)))); + -- Perform minor decoration as this information will be needed for + -- the creation of index checks (if applicable). + + Set_Ekind (Temp, E_Constant); + Set_Etype (Temp, Typ); + -- Replace the original attribute with a reference to the constant Rewrite (LE, New_Reference_To (Temp, Loc)); Set_Etype (LE, Typ); + -- Analysis converts attribute references of the following form + + -- Prefix'Loop_Entry (Expr) + -- Prefix'Loop_Entry (Expr1, Expr2, ... ExprN) + + -- into indexed components for error detection purposes. Generate + -- index checks now that 'Loop_Entry has been properly expanded. + + if Nkind (Parent (LE)) = N_Indexed_Component then + Generate_Index_Checks (Parent (LE)); + end if; + Next_Elmt (LE_Elmt); end loop; Index: checks.adb =================================================================== --- checks.adb (revision 194848) +++ checks.adb (working copy) @@ -5522,6 +5522,23 @@ or else Index_Checks_Suppressed (Etype (A)) then return; + + -- The indexed component we are dealing with contains 'Loop_Entry in its + -- prefix. This case arises when analysis has determined that constructs + -- such as + + -- Prefix'Loop_Entry (Expr) + -- Prefix'Loop_Entry (Expr1, Expr2, ... ExprN) + + -- require rewriting for error detection purposes. A side effect of this + -- action is the generation of index checks that mention 'Loop_Entry. + -- Delay the generation of the check until 'Loop_Entry has been properly + -- expanded. This is done in Expand_Loop_Entry_Attributes. + + elsif Nkind (Prefix (N)) = N_Attribute_Reference + and then Attribute_Name (Prefix (N)) = Name_Loop_Entry + then + return; end if; -- Generate a raise of constraint error with the appropriate reason and