prj-part.adb (Check_Import_Aggregate): New procedure to check if an imported project...
authorVincent Celier <celier@adacore.com>
Wed, 29 Jan 2014 15:35:09 +0000 (15:35 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 29 Jan 2014 15:35:09 +0000 (16:35 +0100)
2014-01-29  Vincent Celier  <celier@adacore.com>

* prj-part.adb (Check_Import_Aggregate): New procedure
to check if an imported project is an aggregate project.
(Parse_Single_Project): Call Check_Import_Aggregate
* projects.texi: Document that aggregate projects cannot be
extended or imported.

From-SVN: r207254

gcc/ada/ChangeLog
gcc/ada/prj-part.adb
gcc/ada/projects.texi

index 43d4f4244b915306b8a3dee6d9de6a099d6b88f8..24d4801f8568a8886c177015901dfefdb0c33415 100644 (file)
@@ -1,3 +1,11 @@
+2014-01-29  Vincent Celier  <celier@adacore.com>
+
+       * prj-part.adb (Check_Import_Aggregate): New procedure
+       to check if an imported project is an aggregate project.
+       (Parse_Single_Project): Call Check_Import_Aggregate
+       * projects.texi: Document that aggregate projects cannot be
+       extended or imported.
+
 2014-01-29  Robert Dewar  <dewar@adacore.com>
 
        * exp_ch9.adb, sem_ch7.ads, s-regexp.adb, sem_ch13.adb: Minor
index ffcd69a2733a4ebf56a4a37feac503febdd06157..53847350ed193a0defe718596289279b9499579d 100644 (file)
@@ -151,6 +151,13 @@ package body Prj.Part is
       Project : Project_Node_Id);
    --  Check that an aggregate project only imports abstract projects
 
+   procedure Check_Import_Aggregate
+     (Flags   : Processing_Flags;
+      In_Tree : Project_Node_Tree_Ref;
+      Project : Project_Node_Id);
+   --  Check that a non aggregate project does not import any aggregate
+   --  project.
+
    procedure Create_Virtual_Extending_Project
      (For_Project     : Project_Node_Id;
       Main_Project    : Project_Node_Id;
@@ -1100,6 +1107,35 @@ package body Prj.Part is
       end if;
    end Check_Aggregate_Imports;
 
+   ----------------------------
+   -- Check_Import_Aggregate --
+   ----------------------------
+
+   procedure Check_Import_Aggregate
+     (Flags   : Processing_Flags;
+      In_Tree : Project_Node_Tree_Ref;
+      Project : Project_Node_Id)
+   is
+      With_Clause, Imported : Project_Node_Id;
+   begin
+      if Project_Qualifier_Of (Project, In_Tree) /= Aggregate then
+         With_Clause := First_With_Clause_Of (Project, In_Tree);
+
+         while Present (With_Clause) loop
+            Imported := Project_Node_Of (With_Clause, In_Tree);
+
+            if Project_Qualifier_Of (Imported, In_Tree) = Aggregate then
+               Error_Msg_Name_1 := Name_Id (Path_Name_Of (Imported, In_Tree));
+               Error_Msg (Flags, "cannot import aggregate project %%",
+                          Token_Ptr);
+               exit;
+            end if;
+
+            With_Clause := Next_With_Clause_Of (With_Clause, In_Tree);
+         end loop;
+      end if;
+   end Check_Import_Aggregate;
+
    ----------------------------
    -- Read_Project_Qualifier --
    ----------------------------
@@ -1767,6 +1803,7 @@ package body Prj.Part is
 
       Check_Extending_All_Imports (Env.Flags, In_Tree, Project);
       Check_Aggregate_Imports (Env.Flags, In_Tree, Project);
+      Check_Import_Aggregate (Env.Flags, In_Tree, Project);
 
       --  Check that a project with a name including a dot either imports
       --  or extends the project whose name precedes the last dot.
index af3387492cc2bcaca363d43231e2196dc2a4243c..e0ef989590413cc9240ce598508de83e7a7194b2 100644 (file)
@@ -2474,8 +2474,8 @@ so that all files are searched for only once on the disk
 (thus reducing the number of system calls and contributing to faster
 compilation times especially on systems with sources on remote
 servers). As part of the loading, @command{gprbuild}
-computes how and where a source file should be compiled, and even if it is found
-several times in the aggregated projects it will be compiled only
+computes how and where a source file should be compiled, and even if it is
+found several times in the aggregated projects it will be compiled only
 once.
 
 Since there is no ambiguity as to which switches should be used, files
@@ -2494,9 +2494,10 @@ recommended extension is still @file{.gpr}. However, a special
 @code{project}.
 
 An aggregate project cannot @code{with} any other project (standard or
-aggregate), except an abstract project which can be used to share
-attribute values. Building other aggregate projects from an aggregate
-project is done through the Project_Files attribute (see below).
+aggregate), except an abstract project which can be used to share attribute
+values. Also, aggregate projects cannot be extended or imported though a
+@code{with} clause by any other project. Building other aggregate projects from
+an aggregate project is done through the Project_Files attribute (see below).
 
 An aggregate project does not have any source files directly (only
 through other standard projects). Therefore a number of the standard
@@ -2548,11 +2549,13 @@ attribute nor the @code{Library_*} attributes, and the result will be to
 build all their source files (not just the ones needed by other
 projects).
 
-The file can include paths (absolute or relative). Paths are
-relative to the location of the aggregate project file itself (if
-you use a base name, we expect to find the .gpr file in the same
-directory as the aggregate project file). The extension @file{.gpr} is
-mandatory, since this attribute contains file names, not project names.
+The file can include paths (absolute or relative). Paths are relative to
+the location of the aggregate project file itself (if you use a base name,
+we expect to find the .gpr file in the same directory as the aggregate
+project file). The environment variables @code{ADA_PROJECT_PATH},
+@code{GPR_PROJECT_PATH} and @code{GPR_PROJECT_PATH_FILE} are not used to find
+the project files. The extension @file{.gpr} is mandatory, since this attribute
+contains file names, not project names.
 
 Paths can also include the @code{"*"} and @code{"**"} globbing patterns. The
 latter indicates that any subdirectory (recursively) will be
@@ -2936,7 +2939,9 @@ The only package that is authorized (albeit optional) is Builder.
 
 The Project_Files attribute (See @pxref{Aggregate Projects}) is used to
 described the aggregated projects whose object files have to be
-included into the aggregate library.
+included into the aggregate library. The environment variables
+@code{ADA_PROJECT_PATH}, @code{GPR_PROJECT_PATH} and
+@code{GPR_PROJECT_PATH_FILE} are not used to find the project files.
 
 @c ---------------------------------------------
 @node Project File Reference