From patchwork Mon Oct 11 15:47:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 67432 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 0F7C0B70A6 for ; Tue, 12 Oct 2010 02:47:53 +1100 (EST) Received: (qmail 21432 invoked by alias); 11 Oct 2010 15:47:51 -0000 Received: (qmail 21380 invoked by uid 22791); 11 Oct 2010 15:47:48 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Oct 2010 15:47:40 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 03740CB0238; Mon, 11 Oct 2010 17:47:38 +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 EJcsTYrNEa0g; Mon, 11 Oct 2010 17:47:37 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id E4219CB01ED; Mon, 11 Oct 2010 17:47:37 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id C6715D9BB5; Mon, 11 Oct 2010 17:47:37 +0200 (CEST) Date: Mon, 11 Oct 2010 17:47:37 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Properly delay Address aspect Message-ID: <20101011154737.GA27964@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 cleans up a glitch in handling address clauses that caused difficulty in the delay case, this is now fixed, and address clauses are properly delayed as seen from this test, which compiles and executes quietly with -gnat12 -gnata 1. with System; use System; 2. with System.Storage_Elements; 3. use System.Storage_Elements; 4. procedure Delayaddr is 5. A : Integer; 6. type R is new integer range 1 .. 2; 7. AA : constant Address := A'Address; 8. B : Integer with Address => AA + R'Size - 8; 9. for R'Size use 8; 10. begin 11. pragma Assert (A'Address = B'Address); 12. end; Prior to this patch, this program was rejected since R was prematurely frozen in line 8, resulting in the rejection of the rep clause in line 9. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-11 Robert Dewar * debug.adb: Remove d.A flag to delay address clause (not needed any more). Add d.A flag to enable tree read/write of aspect spec hash table * sem_ch13.adb (Analyze_Aspect_Specifications): Properly delay address clause. (Rep_Item_Too_Late): No need for special processing for delayed rep items (and it caused difficulties in the address case). * tree_gen.adb: Only write aspect spec hash table if -gnatd.A is set * tree_in.adb: Only write aspect spec hash table if -gnatd.A is set Index: tree_gen.adb =================================================================== --- tree_gen.adb (revision 165300) +++ tree_gen.adb (working copy) @@ -25,6 +25,7 @@ with Aspects; with Atree; +with Debug; with Elists; with Fname; with Lib; @@ -51,7 +52,13 @@ begin if Opt.Tree_Output then Osint.C.Tree_Create; Opt.Tree_Write; - Aspects.Tree_Write; + + -- For now, only write aspect specifications hash table if -gnatd.A set + + if Debug.Debug_Flag_Dot_AA then + Aspects.Tree_Write; + end if; + Atree.Tree_Write; Elists.Tree_Write; Fname.Tree_Write; Index: debug.adb =================================================================== --- debug.adb (revision 165300) +++ debug.adb (working copy) @@ -118,7 +118,7 @@ package body Debug is -- d.y -- d.z - -- d.A Properly defer address aspect + -- d.A Read/write Aspect_Specifications hash table to tree -- d.B -- d.C Generate concatenation call, do not generate inline code -- d.D @@ -558,11 +558,10 @@ package body Debug is -- d.w This flag turns off the scanning of loops to detect possible -- infinite loops. - -- d.A Properly defer address aspect. In the case where the expression - -- of an address aspect is non-static, we should defer the evaluation - -- of the expression till the freeze point, but this does not seem to - -- work properly. So we have this debug switch temporarily so that we - -- can easily investigate this problem. + -- d.A There seems to be a problem with ASIS if we activate the circuit + -- for reading and writing the aspect specification hash table, so + -- for now, this is controlled by the debug flag d.A. The hash table + -- is only written and read if this flag is set. -- d.x No exception handlers in generated code. This causes exception -- handlers to be eliminated from the generated code. They are still Index: tree_in.adb =================================================================== --- tree_in.adb (revision 165300) +++ tree_in.adb (working copy) @@ -32,6 +32,7 @@ with Aspects; with Atree; with Csets; +with Debug; with Elists; with Fname; with Lib; @@ -51,7 +52,13 @@ procedure Tree_In (Desc : File_Descripto begin Tree_IO.Tree_Read_Initialize (Desc); Opt.Tree_Read; - Aspects.Tree_Read; + + -- For now, only read aspect specifications hash table if -gnatd.A is set + + if Debug.Debug_Flag_Dot_AA then + Aspects.Tree_Read; + end if; + Atree.Tree_Read; Elists.Tree_Read; Fname.Tree_Read; Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 165300) +++ sem_ch13.adb (working copy) @@ -26,7 +26,6 @@ with Aspects; use Aspects; with Atree; use Atree; with Checks; use Checks; -with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; @@ -765,7 +764,8 @@ package body Sem_Ch13 is -- Aspects corresponding to attribute definition clauses with -- the exception of Address which is treated specially. - when Aspect_Alignment | + when Aspect_Address | + Aspect_Alignment | Aspect_Bit_Order | Aspect_Component_Size | Aspect_External_Tag | @@ -780,6 +780,8 @@ package body Sem_Ch13 is -- Preanalyze the expression with the appropriate type case A_Id is + when Aspect_Address => + T := RTE (RE_Address); when Aspect_Bit_Order => T := RTE (RE_Bit_Order); when Aspect_External_Tag => @@ -811,38 +813,6 @@ package body Sem_Ch13 is Delay_Required := True; end if; - -- Address aspect, treated specially because we have some - -- strange problem in the back end if we try to delay ??? - - when Aspect_Address => - - -- Construct the attribute definition clause - - Aitem := - Make_Attribute_Definition_Clause (Sloc (Aspect), - Name => Ent, - Chars => Chars (Id), - Expression => Relocate_Node (Expr)); - - -- If -gnatd.A is set, do the delay if needed (this is - -- so we can debug the relevant problem). - - if Debug_Flag_Dot_AA then - Preanalyze_Spec_Expression - (Expression (Aitem), RTE (RE_Address)); - - if Is_OK_Static_Expression (Expression (Aitem)) then - Delay_Required := False; - else - Delay_Required := True; - end if; - - -- Here if -gnatd.A not set, never do the delay - - else - Delay_Required := False; - end if; - -- Aspects corresponding to pragmas with two arguments, where -- the first argument is a local name referring to the entity, -- and the second argument is the aspect definition expression. @@ -1190,8 +1160,8 @@ package body Sem_Ch13 is A : Node_Id; begin - -- Nothing to do if this attribute definition clause comes from an - -- aspect specification, since we could not be duplicating an + -- Nothing to do if this attribute definition clause comes from + -- an aspect specification, since we could not be duplicating an -- explicit clause, and we dealt with the case of duplicated aspects -- in Analyze_Aspect_Specifications. @@ -5022,17 +4992,6 @@ package body Sem_Ch13 is -- Start of processing for Rep_Item_Too_Late begin - -- If this is from an aspect that was delayed till the freeze point, - -- then we skip this check entirely, since it is not required and - -- furthermore can generate false errors. Also we don't need to chain - -- the item into the rep item chain in that case, it is already there! - - if Nkind_In (N, N_Attribute_Definition_Clause, N_Pragma) - and then Is_Delayed_Aspect (N) - then - return False; - end if; - -- First make sure entity is not frozen (RM 13.1(9)). Exclude imported -- types, which may be frozen if they appear in a representation clause -- for a local type.