From patchwork Mon Oct 29 11:01:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 194964 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 1466D2C0084 for ; Mon, 29 Oct 2012 22:01:54 +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=1352113315; 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=AUJBxgpxKa+gzrggJwvq xZancL8=; b=jJy8PMeG3VYMk77M/FG7Qbmh6fn+wQl22/7Tp8gvbHGWS5EHRvSE jz/pR69axhQfHpgBqrF2Yqw8vmZ4WFNYnwK4z4TCQ/+TVYxgfqiAlqyFhy2oU3Sg /g5toTpQfx4u4D5xpm3/uaVL3aYc6ldAO4djsnmGB2yro4tIb1YugQ8= 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=Gc1q6Zx2erjZceyfM5HTb+VFMaSCU/2jnZmPKpLtzLwpNmyFiRAkmNQ4HweDLW ZXhIVOt7R2DjNvqYmFdNeXbgOPAwuERuKkodNQGCm4Fp2Fb7+y7rgL/0yh+3vwiT 7JaBBo5ORkqiJrzA5kIsChSxXYLSeVKvY6GkNH5NESIYc=; Received: (qmail 29335 invoked by alias); 29 Oct 2012 11:01:47 -0000 Received: (qmail 29326 invoked by uid 22791); 29 Oct 2012 11:01:47 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO, TW_TX 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; Mon, 29 Oct 2012 11:01:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B052C1C7F86; Mon, 29 Oct 2012 07:01:35 -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 VTSTvd4Nl+4D; Mon, 29 Oct 2012 07:01:35 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8D7FE1C7F80; Mon, 29 Oct 2012 07:01:35 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 872A83FF09; Mon, 29 Oct 2012 07:01:35 -0400 (EDT) Date: Mon, 29 Oct 2012 07:01:35 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Emmanuel Briot Subject: [Ada] Duplicate entries for parameters in gnatxref output Message-ID: <20121029110135.GA17157@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 a call to a subprogram in another package uses named parameters, gnatxref will sometimes output duplicate entries for the parameter, depending on the order in which the ALI files are read. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-10-29 Emmanuel Briot * xr_tabls.adb, xr_tabls.ads (Add_Declaration, Add_Reference): No longer assume that a parameter declaration is seen after the subprogram that uses it. Index: xr_tabls.adb =================================================================== --- xr_tabls.adb (revision 192918) +++ xr_tabls.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2012, 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- -- @@ -223,6 +223,7 @@ Line : Natural; Column : Natural; Decl_Type : Character; + Is_Parameter : Boolean := False; Remove_Only : Boolean := False; Symbol_Match : Boolean := True) return Declaration_Reference @@ -235,7 +236,7 @@ New_Decl : Declaration_Reference := Entities_HTable.Get (Key'Unchecked_Access); - Is_Parameter : Boolean := False; + Is_Param : Boolean := Is_Parameter; begin -- Insert the Declaration in the table. There might already be a @@ -243,7 +244,7 @@ -- need to check that first. if New_Decl /= null and then New_Decl.Symbol_Length = 0 then - Is_Parameter := New_Decl.Is_Parameter; + Is_Param := Is_Parameter or else New_Decl.Is_Parameter; Entities_HTable.Remove (Key'Unrestricted_Access); Entities_Count := Entities_Count - 1; Free (New_Decl.Key); @@ -269,7 +270,7 @@ Column => Column, Source_Line => null, Next => null), - Is_Parameter => Is_Parameter, + Is_Parameter => Is_Param, Decl_Type => Decl_Type, Body_Ref => null, Ref_Ref => null, @@ -294,6 +295,10 @@ then New_Decl.Match := Default_Match or else Match (File_Ref, Line, Column); + New_Decl.Is_Parameter := New_Decl.Is_Parameter or else Is_Param; + + elsif New_Decl /= null then + New_Decl.Is_Parameter := New_Decl.Is_Parameter or else Is_Param; end if; return New_Decl; @@ -392,6 +397,8 @@ Labels_As_Ref : Boolean) is New_Ref : Reference; + New_Decl : Declaration_Reference; + pragma Unreferenced (New_Decl); begin case Ref_Type is @@ -407,37 +414,22 @@ when '=' | '<' | '>' | '^' => -- Create a dummy declaration in the table to report it as a - -- parameter. Note that the current declaration for the subprogram - -- comes before the declaration of the parameter. + -- parameter. + -- In a given ALI file, the declaration of the subprogram comes + -- before the declaration of the parameter. However, it is + -- possible that another ALI file has been parsed that also + -- references the parameter (for instance a named parameter in a + -- call), so we need to check whether there already exists a + -- declaration for the parameter. - declare - Key : constant String := - Key_From_Ref (File_Ref, Line, Column); - New_Decl : Declaration_Reference; + New_Decl := Add_Declaration + (File_Ref => File_Ref, + Symbol => "", + Line => Line, + Column => Column, + Decl_Type => ' ', + Is_Parameter => True); - begin - New_Decl := new Declaration_Record' - (Symbol_Length => 0, - Symbol => "", - Key => new String'(Key), - Decl => new Reference_Record' - (File => File_Ref, - Line => Line, - Column => Column, - Source_Line => null, - Next => null), - Is_Parameter => True, - Decl_Type => ' ', - Body_Ref => null, - Ref_Ref => null, - Modif_Ref => null, - Match => False, - Par_Symbol => null, - Next => null); - Entities_HTable.Set (New_Decl); - Entities_Count := Entities_Count + 1; - end; - when 'e' | 'z' | 't' | 'p' | 'P' | 'k' | 'd' => return; Index: xr_tabls.ads =================================================================== --- xr_tabls.ads (revision 192918) +++ xr_tabls.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1998-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2012, 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- -- @@ -78,6 +78,7 @@ Line : Natural; Column : Natural; Decl_Type : Character; + Is_Parameter : Boolean := False; Remove_Only : Boolean := False; Symbol_Match : Boolean := True) return Declaration_Reference; @@ -89,6 +90,8 @@ -- the command line. In that case, the entity will not be output by -- gnatfind. If Symbol_Match is True, the entity will only be output if the -- file name itself matches. + -- Is_Parameter should be set to True if the entity is known to be a + -- subprogram parameter. procedure Add_Parent (Declaration : in out Declaration_Reference;