prj-nmsc.adb (Language_Independent_Check): Do not forbid virtual extension of library...
authorVincent Celier <celier@gnat.com>
Wed, 27 Oct 2004 13:38:58 +0000 (15:38 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 27 Oct 2004 13:38:58 +0000 (15:38 +0200)
2004-10-26  Vincent Celier  <celier@gnat.com>

* prj-nmsc.adb (Language_Independent_Check): Do not forbid virtual
extension of library projects.

* prj-part.adb: If env var ADA_PROJECT_PATH is not defined, project
path defaults to ".:<prefix>/lib/gnat".
(Parse): For an extending all project, allow direct import of a project
that is virtually extended.

* prj-proc.adb (Imported_Or_Extended_Project_From): If a project with
the specified name is directly imported, return its ID. Otherwise, if
an extension of this project is imported, return the ID of the
extension.

From-SVN: r89662

gcc/ada/prj-nmsc.adb
gcc/ada/prj-part.adb
gcc/ada/prj-proc.adb

index c3193b8098ee5dc7c4617e3d59c34e5f8a7f14f7..8bca19c660a3c18bba4021508524241948567052 100644 (file)
@@ -3522,22 +3522,7 @@ package body Prj.Nmsc is
                   end if;
 
                   if Lib_Dir.Default then
-
-                     --  If the extending project is a virtual project, we
-                     --  put the error message in the library project that
-                     --  is extended, rather than in the extending all project.
-                     --  Of course, we cannot put it in the virtual extending
-                     --  project, because it has no source.
-
-                     if Data.Virtual then
-                        Error_Msg_Name_1 := Extended_Data.Name;
-
-                        Error_Msg
-                          (Project,
-                           "library project % cannot be virtually extended",
-                           Extended_Data.Location);
-
-                     else
+                     if not Data.Virtual then
                         Error_Msg
                           (Project,
                            "a project extending a library project must " &
index 63700b0d0102ce4d03b9c806b1b1aac19a259752..c09f8fa803aed138c4d3b2fdef71b4fd233f38c4 100644 (file)
@@ -33,6 +33,7 @@ with Prj.Com;  use Prj.Com;
 with Prj.Dect;
 with Prj.Err;  use Prj.Err;
 with Scans;    use Scans;
+with Sdefault;
 with Sinput;   use Sinput;
 with Sinput.P; use Sinput.P;
 with Snames;
@@ -531,11 +532,6 @@ package body Prj.Part is
                            Virtual_Hash.Remove (Imported);
                            Declaration := Project_Declaration_Of (Imported);
                         end loop;
-
-                     elsif Virtual_Hash.Get (Imported) /= Empty_Node then
-                        Error_Msg
-                          ("this project cannot be imported directly",
-                           Location_Of (With_Clause));
                      end if;
 
                   end if;
@@ -1708,7 +1704,10 @@ begin
    --  Initialize Project_Path during package elaboration
 
    if Prj_Path.all = "" then
-      Project_Path := new String'(".");
+      Project_Path :=
+        new String'("." & Path_Separator & Sdefault.Search_Dir_Prefix.all &
+                    ".." & Directory_Separator & ".." & Directory_Separator &
+                    ".." & Directory_Separator & "gnat");
    else
       Project_Path := new String'("." & Path_Separator & Prj_Path.all);
    end if;
index 5df87a08fa30e5b104ac5b37b971e7a6e129f15c..561c5d43809359989b101ce1fd54492672000def 100644 (file)
@@ -762,11 +762,13 @@ package body Prj.Proc is
      (Project   : Project_Id;
       With_Name : Name_Id) return Project_Id
    is
-      Data : constant Project_Data := Projects.Table (Project);
-      List : Project_List          := Data.Imported_Projects;
+      Data        : constant Project_Data := Projects.Table (Project);
+      List        : Project_List          := Data.Imported_Projects;
+      Result      : Project_Id := No_Project;
+      Temp_Result : Project_Id := No_Project;
 
    begin
-      --  First check if it is the name of a extended project
+      --  First check if it is the name of an extended project
 
       if Data.Extends /= No_Project
         and then Projects.Table (Data.Extends).Name = With_Name
@@ -776,20 +778,40 @@ package body Prj.Proc is
       else
          --  Then check the name of each imported project
 
-         while List /= Empty_Project_List
-           and then
-             Projects.Table
-               (Project_Lists.Table (List).Project).Name /= With_Name
+         while List /= Empty_Project_List loop
+            Result := Project_Lists.Table (List).Project;
+
+            --  If the project is directly imported, then returns its ID
+
+            if Projects.Table (Result).Name = With_Name then
+               return Result;
+            end if;
+
+            --  If a project extending the project is imported, then keep
+            --  this extending project as a possibility. It will be the
+            --  returned ID if the project is not imported directly.
+
+            declare
+               Proj : Project_Id := Projects.Table (Result).Extends;
+            begin
+               while Proj /= No_Project loop
+                  if Projects.Table (Proj).Name = With_Name then
+                     Temp_Result := Result;
+                     exit;
+                  end if;
+
+                  Proj := Projects.Table (Proj).Extends;
+               end loop;
+            end;
 
-         loop
             List := Project_Lists.Table (List).Next;
          end loop;
 
          pragma Assert
-           (List /= Empty_Project_List,
+           (Temp_Result /= No_Project,
            "project not found");
 
-         return Project_Lists.Table (List).Project;
+         return Temp_Result;
       end if;
    end Imported_Or_Extended_Project_From;