From patchwork Tue Jun 22 10:16:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56451 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 990E1B6F0C for ; Tue, 22 Jun 2010 20:16:28 +1000 (EST) Received: (qmail 26056 invoked by alias); 22 Jun 2010 10:16:24 -0000 Received: (qmail 26035 invoked by uid 22791); 22 Jun 2010 10:16:22 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_PR, 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; Tue, 22 Jun 2010 10:16:13 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id C7705CB02A0; Tue, 22 Jun 2010 12:16:14 +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 y6i-xWjAmwoM; Tue, 22 Jun 2010 12:16:14 +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 B4CE7CB027F; Tue, 22 Jun 2010 12:16:14 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id A6447D9B31; Tue, 22 Jun 2010 12:16:14 +0200 (CEST) Date: Tue, 22 Jun 2010 12:16:14 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] Two library projects cannot have the same library name Message-ID: <20100622101614.GA16018@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 The Project Manager now detects if two library projects that do not extend each other have the same library name and fails if they do. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-22 Vincent Celier * prj-nmsc.adb (Lib_Data_Table): New table. (Check_Library_Attributes): Check if the same library name is used in two different projects that do not extend each other. Index: prj-nmsc.adb =================================================================== --- prj-nmsc.adb (revision 161131) +++ prj-nmsc.adb (working copy) @@ -26,6 +26,7 @@ with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.Dynamic_HTables; +with GNAT.Table; with Err_Vars; use Err_Vars; with Opt; use Opt; @@ -157,6 +158,20 @@ -- This data must be initialized before processing any project, and the -- same data is used for processing all projects in the tree. + type Lib_Data is record + Name : Name_Id; + Proj : Project_Id; + end record; + + package Lib_Data_Table is new GNAT.Table + (Table_Component_Type => Lib_Data, + Table_Index_Type => Positive, + Table_Low_Bound => 1, + Table_Initial => 10, + Table_Increment => 100); + -- A table to record library names in order to check that two library + -- projects do not have the same library names. + procedure Initialize (Data : out Tree_Processing_Data; Tree : Project_Tree_Ref; @@ -4083,9 +4098,46 @@ end; end if; - if Project.Extends /= No_Project then + if Project.Extends /= No_Project and then Project.Extends.Library then + + -- Remove the library name from Lib_Data_Table + + for J in 1 .. Lib_Data_Table.Last loop + if Lib_Data_Table.Table (J).Proj = Project.Extends then + Lib_Data_Table.Table (J) := + Lib_Data_Table.Table (Lib_Data_Table.Last); + Lib_Data_Table.Set_Last (Lib_Data_Table.Last - 1); + exit; + end if; + end loop; + Project.Extends.Library := False; end if; + + if Project.Library and then not Lib_Name.Default then + + -- Check if the same library name is used in an other library project + + for J in 1 .. Lib_Data_Table.Last loop + if Lib_Data_Table.Table (J).Name = Project.Library_Name then + Error_Msg_Name_1 := Lib_Data_Table.Table (J).Proj.Name; + Error_Msg + (Data.Flags, + "Library name cannot be the same as in project %%", + Lib_Name.Location, Project); + Project.Library := False; + exit; + end if; + end loop; + end if; + + if Project.Library then + + -- Record the library name + + Lib_Data_Table.Append + ((Name => Project.Library_Name, Proj => Project)); + end if; end Check_Library_Attributes; ---------------------------------