Patchwork [Ada] All duplicate units in a project now reported

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 8, 2010, 10:45 a.m.
Message ID <20101008104529.GA23112@adacore.com>
Download mbox | patch
Permalink /patch/67165/
State New
Headers show

Comments

Arnaud Charlet - Oct. 8, 2010, 10:45 a.m.
If there are several duplicate units in a project, they are all reported once.
The test for this is to invoke gnatmake on a project with duplicate units "a"
and "b" in the same source directory subtree (".../**"). Both duplicate units
"a" and "b" should be reported.

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-10-08  Vincent Celier  <celier@adacore.com>

	* prj-nmsc.adb (Add_Source): Report all duplicate units and source file
	names.  Do not report the same duplicate unit several times.
	* prj.ads (Source_Data): New Boolean component Duplicate_Unit,
	defaulted to False, to avoid reporting the same unit as duplicate
	several times.

Patch

Index: prj.ads
===================================================================
--- prj.ads	(revision 165084)
+++ prj.ads	(working copy)
@@ -765,6 +765,9 @@  package Prj is
       Naming_Exception : Boolean := False;
       --  True if the source has an exceptional name
 
+      Duplicate_Unit : Boolean := False;
+      --  True when a duplicate unit has been reported for this source
+
       Next_In_Lang : Source_Id := No_Source;
       --  Link to another source of the same language in the same project
    end record;
@@ -799,6 +802,7 @@  package Prj is
                        Switches_Path          => No_Path,
                        Switches_TS            => Empty_Time_Stamp,
                        Naming_Exception       => False,
+                       Duplicate_Unit         => False,
                        Next_In_Lang           => No_Source);
 
    package Source_Paths_Htable is new Simple_HTable
Index: prj-nmsc.adb
===================================================================
--- prj-nmsc.adb	(revision 165152)
+++ prj-nmsc.adb	(working copy)
@@ -705,9 +705,13 @@  package body Prj.Nmsc is
                --  (for instance because of symbolic links).
 
                elsif Source.Path.Name /= Path.Name then
-                  Error_Msg_Name_1 := Unit;
-                  Error_Msg
-                    (Data.Flags, "duplicate unit %%", Location, Project);
+                  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;
+
                   Add_Src := False;
                end if;
             end if;