From patchwork Wed Feb 6 10:20:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 218532 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 785242C02C1 for ; Wed, 6 Feb 2013 21:20:47 +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=1360750847; 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=jCWaTyHiabmNVOEvrAQD 9Y3wu1w=; b=GGtiEtGYBPs9XZIDBQpHVRSNhGIjF3QTjfTmjDPbjgI5yzqWg9c4 H9G/cbbIbmAMUUI0hu+9dwD7gi5gbsddEsvhcoJlLw/e1ZYXLEwKjRuAEexiPbym tWh3V7glZoUHyOEeVoyCByjy/LEdbumhXJhBWH/u2hf4BabVxEdPt0I= 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=u4sc4b3kBPZ2NeQWYGiwa8QL45YYxO1xIwBL7yHZhl5iDonKIKHHTDFu/BiKcA LzVsCrTuUQJcVUOM8kMaPdIOk7EPf/qfA1h+xB7yAOUy2JL22t0S/cBiLNxL7Z4F n3IHKYGBDby1YpMVtztVkz4iI56eOE18HCBTmrEYUU9jI=; Received: (qmail 27737 invoked by alias); 6 Feb 2013 10:20:28 -0000 Received: (qmail 27700 invoked by uid 22791); 6 Feb 2013 10:20:28 -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; Wed, 06 Feb 2013 10:20:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7939D2E618; Wed, 6 Feb 2013 05:20:21 -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 R2qULjsWBPs2; Wed, 6 Feb 2013 05:20:21 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 56AC62E612; Wed, 6 Feb 2013 05:20:21 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 5671C3FF09; Wed, 6 Feb 2013 05:20:21 -0500 (EST) Date: Wed, 6 Feb 2013 05:20:21 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Hristian Kirtchev Subject: [Ada] Crash when processing attribute Loop_Entry Message-ID: <20130206102021.GA23863@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 suppresses the resolution of the prefix of attribute Loop_Entry. The resolution still takes place after Loop_Entry has been transformed into the initialization expression of a constant. The delay ensures that any generated checks or temporaries are inserted before the relocated prefix. ------------- -- Sources -- ------------- -- main.adb: with Ada.Text_IO; use Ada.Text_IO; procedure Main is type Int_Array is array (Natural range <>) of Natural; procedure Process_Array (Obj : Int_Array) is Var : Natural := 0; begin for Index in Natural range Obj'Range loop Var := Var + 1; pragma Loop_Invariant (Obj (Obj'First + Var)'Loop_Entry >= 10); end loop; Put_Line (Integer'Image (Var)); end Process_Array; X : Int_Array (1 .. 0); begin Process_Array (X); end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q -gnat12 -gnata -gnatd.V main.adb $ ./main 0 Tested on x86_64-pc-linux-gnu, committed on trunk 2013-02-06 Hristian Kirtchev * sem_attr.adb (Resolve_Attribute): Do not resolve the prefix of Loop_Entry, instead wait until the attribute has been expanded. The delay ensures that any generated checks or temporaries are inserted before the relocated prefix. Index: sem_attr.adb =================================================================== --- sem_attr.adb (revision 195784) +++ sem_attr.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, 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- -- @@ -9821,6 +9821,18 @@ when Attribute_Enabled => null; + ---------------- + -- Loop_Entry -- + ---------------- + + -- Do not resolve the prefix of Loop_Entry, instead wait until the + -- attribute has been expanded (see Expand_Loop_Entry_Attributes). + -- The delay ensures that any generated checks or temporaries are + -- inserted before the relocated prefix. + + when Attribute_Loop_Entry => + null; + -------------------- -- Mechanism_Code -- --------------------