From patchwork Tue May 15 09:27:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 159272 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 293AEB6FB7 for ; Tue, 15 May 2012 19:27:58 +1000 (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=1337678879; 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=RpjKt5tXR6NGuxausyC4 MU7IZro=; b=tjp3QPTF129QUgl3Zfzvnwd8FUG0E000FWheSKFYT967deUzg3rr jkuvGih/ALlUVJiNn9Sv3RSycBtNv3SV7f0m32tvpVeR/eZSeY7WGuOAzJKnTSFJ 9uD9HPd6DtCOOA04zBuTD+mr3J6+68hYrX5xcGTWp9PLG67pNJj9hN8= 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=mCBg3oKbi7tCzDw8SEPeVml0QBa/fqCJM6w2ZBotHffvv0oPpzp25gaB/c9c/7 CJWX1Py/UmIwAVHjwyiysdvS7lM2PjVI+M50txox3zS+HlkZYGAZDebnBzr/Pkbw apwtKHK+BwyHuKJhPbNKIGQ4dZH7adJTMJYLt9WZ91zYQ=; Received: (qmail 15058 invoked by alias); 15 May 2012 09:27:30 -0000 Received: (qmail 14875 invoked by uid 22791); 15 May 2012 09:27:22 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, TW_PR 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; Tue, 15 May 2012 09:27:05 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6484B1C6E35; Tue, 15 May 2012 05:27:04 -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 iERh42H1JGC1; Tue, 15 May 2012 05:27:04 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 3EF391C6E2C; Tue, 15 May 2012 05:27:04 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 3F40E92BF6; Tue, 15 May 2012 05:27:04 -0400 (EDT) Date: Tue, 15 May 2012 05:27:04 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] Avoid incorrect detection of duplicate sources that are excluded Message-ID: <20120515092703.GA25600@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 If two projects in the hierarchy had a common source directory but through exclusion partitioned the sources in this source directory, the project manager was still finding incorrect source duplications. This patch corrects this. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Vincent Celier * prj-nmsc.adb (Add_Source): Always add the source if it is excluded, to avoid incorrect duplicate checks. Index: prj-nmsc.adb =================================================================== --- prj-nmsc.adb (revision 187501) +++ prj-nmsc.adb (working copy) @@ -642,143 +642,153 @@ Add_Src := True; - if Unit /= No_Name then - Prev_Unit := Units_Htable.Get (Data.Tree.Units_HT, Unit); - end if; + -- Always add the source if it is locally removed, to avoid incorrect + -- duplicate checks. - if Prev_Unit /= No_Unit_Index - and then (Kind = Impl or else Kind = Spec) - and then Prev_Unit.File_Names (Kind) /= null - then - -- Suspicious, we need to check later whether this is authorized + if not Locally_Removed then + if Unit /= No_Name then + Prev_Unit := Units_Htable.Get (Data.Tree.Units_HT, Unit); + end if; - Add_Src := False; - Source := Prev_Unit.File_Names (Kind); + if Prev_Unit /= No_Unit_Index + and then (Kind = Impl or else Kind = Spec) + and then Prev_Unit.File_Names (Kind) /= null + then + -- Suspicious, we need to check later whether this is authorized - else - Source := Source_Files_Htable.Get - (Data.Tree.Source_Files_HT, File_Name); + Add_Src := False; + Source := Prev_Unit.File_Names (Kind); - if Source /= No_Source and then Source.Index = Index then - Add_Src := False; + else + Source := Source_Files_Htable.Get + (Data.Tree.Source_Files_HT, File_Name); + + if Source /= No_Source and then Source.Index = Index then + Add_Src := False; + end if; end if; - end if; - -- Duplication of file/unit in same project is allowed if order of - -- source directories is known, or if there is no compiler for the - -- language. + -- Duplication of file/unit in same project is allowed if order of + -- source directories is known, or if there is no compiler for the + -- language. - if Add_Src = False then - Add_Src := True; + if Add_Src = False then + Add_Src := True; - if Project = Source.Project then - if Prev_Unit = No_Unit_Index then - if Data.Flags.Allow_Duplicate_Basenames then - Add_Src := True; + if Project = Source.Project then + if Prev_Unit = No_Unit_Index then + if Data.Flags.Allow_Duplicate_Basenames then + Add_Src := True; - elsif Lang_Id.Config.Compiler_Driver = Empty_File then - Add_Src := True; + elsif Lang_Id.Config.Compiler_Driver = Empty_File then + Add_Src := True; - elsif Source_Dir_Rank /= Source.Source_Dir_Rank then - Add_Src := False; + elsif Source_Dir_Rank /= Source.Source_Dir_Rank then + Add_Src := False; + else + Error_Msg_File_1 := File_Name; + Error_Msg + (Data.Flags, "duplicate source file name {", + Location, Project); + Add_Src := False; + end if; + else - Error_Msg_File_1 := File_Name; - Error_Msg - (Data.Flags, "duplicate source file name {", - Location, Project); - Add_Src := False; - end if; + if Source_Dir_Rank /= Source.Source_Dir_Rank then + Add_Src := False; - else - if Source_Dir_Rank /= Source.Source_Dir_Rank then - Add_Src := False; + -- We might be seeing the same file through a different + -- path (for instance because of symbolic links). - -- We might be seeing the same file through a different path - -- (for instance because of symbolic links). + elsif Source.Path.Name /= Path.Name then + if not Source.Duplicate_Unit then + Error_Msg_Name_1 := Unit; + Error_Msg + (Data.Flags, + "\duplicate unit %%", + Location, + Project); + Source.Duplicate_Unit := True; + end if; - elsif Source.Path.Name /= Path.Name then - if not Source.Duplicate_Unit then - Error_Msg_Name_1 := Unit; - Error_Msg - (Data.Flags, "\duplicate unit %%", Location, Project); - Source.Duplicate_Unit := True; + Add_Src := False; end if; - - Add_Src := False; end if; - end if; - -- Do not allow the same unit name in different projects, except - -- if one is extending the other. + -- Do not allow the same unit name in different projects, + -- except if one is extending the other. - -- For a file based language, the same file name replaces a file - -- in a project being extended, but it is allowed to have the same - -- file name in unrelated projects. + -- For a file based language, the same file name replaces a + -- file in a project being extended, but it is allowed to have + -- the same file name in unrelated projects. - elsif Is_Extending (Project, Source.Project) then - if not Locally_Removed and then Naming_Exception /= Inherited then - Source_To_Replace := Source; - end if; + elsif Is_Extending (Project, Source.Project) then + if not Locally_Removed + and then Naming_Exception /= Inherited + then + Source_To_Replace := Source; + end if; - elsif Prev_Unit /= No_Unit_Index - and then Prev_Unit.File_Names (Kind) /= null - and then not Source.Locally_Removed - and then not Data.In_Aggregate_Lib - then - -- Path is set if this is a source we found on the disk, in which - -- case we can provide more explicit error message. Path is unset - -- when the source is added from one of the naming exceptions in - -- the project. + elsif Prev_Unit /= No_Unit_Index + and then Prev_Unit.File_Names (Kind) /= null + and then not Source.Locally_Removed + and then not Data.In_Aggregate_Lib + then + -- Path is set if this is a source we found on the disk, in + -- which case we can provide more explicit error message. Path + -- is unset when the source is added from one of the naming + -- exceptions in the project. - if Path /= No_Path_Information then - Error_Msg_Name_1 := Unit; - Error_Msg - (Data.Flags, - "unit %% cannot belong to several projects", - Location, Project); + if Path /= No_Path_Information then + Error_Msg_Name_1 := Unit; + Error_Msg + (Data.Flags, + "unit %% cannot belong to several projects", + Location, Project); - Error_Msg_Name_1 := Project.Name; - Error_Msg_Name_2 := Name_Id (Path.Display_Name); - Error_Msg - (Data.Flags, "\ project %%, %%", Location, Project); + Error_Msg_Name_1 := Project.Name; + Error_Msg_Name_2 := Name_Id (Path.Display_Name); + Error_Msg + (Data.Flags, "\ project %%, %%", Location, Project); - Error_Msg_Name_1 := Source.Project.Name; - Error_Msg_Name_2 := Name_Id (Source.Path.Display_Name); - Error_Msg - (Data.Flags, "\ project %%, %%", Location, Project); + Error_Msg_Name_1 := Source.Project.Name; + Error_Msg_Name_2 := Name_Id (Source.Path.Display_Name); + Error_Msg + (Data.Flags, "\ project %%, %%", Location, Project); - else - Error_Msg_Name_1 := Unit; - Error_Msg_Name_2 := Source.Project.Name; - Error_Msg - (Data.Flags, "unit %% already belongs to project %%", - Location, Project); - end if; + else + Error_Msg_Name_1 := Unit; + Error_Msg_Name_2 := Source.Project.Name; + Error_Msg + (Data.Flags, "unit %% already belongs to project %%", + Location, Project); + end if; - Add_Src := False; + Add_Src := False; - elsif not Source.Locally_Removed - and then not Data.Flags.Allow_Duplicate_Basenames - and then Lang_Id.Config.Kind = Unit_Based - and then Source.Language.Config.Kind = Unit_Based - and then not Data.In_Aggregate_Lib - then - Error_Msg_File_1 := File_Name; - Error_Msg_File_2 := File_Name_Type (Source.Project.Name); - Error_Msg - (Data.Flags, - "{ is already a source of project {", Location, Project); + elsif not Source.Locally_Removed + and then not Data.Flags.Allow_Duplicate_Basenames + and then Lang_Id.Config.Kind = Unit_Based + and then Source.Language.Config.Kind = Unit_Based + and then not Data.In_Aggregate_Lib + then + Error_Msg_File_1 := File_Name; + Error_Msg_File_2 := File_Name_Type (Source.Project.Name); + Error_Msg + (Data.Flags, + "{ is already a source of project {", Location, Project); - -- Add the file anyway, to avoid further warnings like "language - -- unknown". + -- Add the file anyway, to avoid further warnings like + -- "language unknown". - Add_Src := True; + Add_Src := True; + end if; end if; - end if; - if not Add_Src then - return; + if not Add_Src then + return; + end if; end if; -- Add the new file