prj-proc.adb (Recursive_Process): Set From_Encapsulated_Lib boolean value to true in the process list created by...

2012-01-30  Pascal Obry  <obry@adacore.com>

	* prj-proc.adb (Recursive_Process): Set From_Encapsulated_Lib
	boolean value to true in the process list created by this routine.
	* prj.ads (Project_List_Element): New field From_Encapsulated_Lib.
	Continued work for KA06-021.
	* prj.adb (Compute_All_Imported_Projects): Set
	From_Encapsulated_Lib boolean flag.

From-SVN: r183703
This commit is contained in:
Pascal Obry 2012-01-30 10:33:44 +00:00 committed by Arnaud Charlet
parent 457c5df44b
commit a76b09dce5
4 changed files with 105 additions and 49 deletions

View File

@ -1,3 +1,12 @@
2012-01-30 Pascal Obry <obry@adacore.com>
* prj-proc.adb (Recursive_Process): Set From_Encapsulated_Lib
boolean value to true in the process list created by this routine.
* prj.ads (Project_List_Element): New field From_Encapsulated_Lib.
Continued work for KA06-021.
* prj.adb (Compute_All_Imported_Projects): Set
From_Encapsulated_Lib boolean flag.
2012-01-30 Vincent Pucci <pucci@adacore.com> 2012-01-30 Vincent Pucci <pucci@adacore.com>
* sem_dim.adb (Expand_Put_Call_With_Dimension_Symbol): Minor * sem_dim.adb (Expand_Put_Call_With_Dimension_Symbol): Minor

View File

@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2011, Free Software Foundation, Inc. -- -- Copyright (C) 2001-2012, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
@ -32,6 +32,7 @@ with Prj.Env;
with Prj.Err; use Prj.Err; with Prj.Err; use Prj.Err;
with Prj.Ext; use Prj.Ext; with Prj.Ext; use Prj.Ext;
with Prj.Nmsc; use Prj.Nmsc; with Prj.Nmsc; use Prj.Nmsc;
with Prj.Util;
with Prj.Part; with Prj.Part;
with Snames; with Snames;
@ -149,7 +150,8 @@ package body Prj.Proc is
From_Project_Node : Project_Node_Id; From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref; From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment; Env : in out Prj.Tree.Environment;
Extended_By : Project_Id); Extended_By : Project_Id;
From_Encapsulated_Lib : Boolean);
-- Process project with node From_Project_Node in the tree. Do nothing if -- Process project with node From_Project_Node in the tree. Do nothing if
-- From_Project_Node is Empty_Node. If project has already been processed, -- From_Project_Node is Empty_Node. If project has already been processed,
-- simply return its project id. Otherwise create a new project id, mark it -- simply return its project id. Otherwise create a new project id, mark it
@ -161,6 +163,9 @@ package body Prj.Proc is
-- explicitly loaded. In the context of aggregate projects, only that -- explicitly loaded. In the context of aggregate projects, only that
-- project is allowed to modify the environment that will be used to load -- project is allowed to modify the environment that will be used to load
-- projects (Child_Env). -- projects (Child_Env).
--
-- From_Encapsulated_Lib is true if we are parsing a project from
-- encapsulated library dependencies.
function Get_Attribute_Index function Get_Attribute_Index
(Tree : Project_Node_Tree_Ref; (Tree : Project_Node_Tree_Ref;
@ -2357,7 +2362,8 @@ package body Prj.Proc is
From_Project_Node => From_Project_Node, From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree, From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env, Env => Env,
Extended_By => No_Project); Extended_By => No_Project,
From_Encapsulated_Lib => False);
Success := Success :=
Total_Errors_Detected = 0 Total_Errors_Detected = 0
@ -2491,7 +2497,8 @@ package body Prj.Proc is
From_Project_Node : Project_Node_Id; From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref; From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment; Env : in out Prj.Tree.Environment;
Extended_By : Project_Id) Extended_By : Project_Id;
From_Encapsulated_Lib : Boolean)
is is
Shared : constant Shared_Project_Tree_Data_Access := In_Tree.Shared; Shared : constant Shared_Project_Tree_Data_Access := In_Tree.Shared;
@ -2550,21 +2557,20 @@ package body Prj.Proc is
Project_Node_Of (With_Clause, From_Project_Node_Tree), Project_Node_Of (With_Clause, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree, From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env, Env => Env,
Extended_By => No_Project); Extended_By => No_Project,
From_Encapsulated_Lib => From_Encapsulated_Lib);
-- Imported is the id of the last imported project. If
-- it is nil, then this imported project is our first.
if Imported = null then if Imported = null then
Project.Imported_Projects := Project.Imported_Projects := new Project_List_Element'
new Project_List_Element' (Project => New_Project,
(Project => New_Project, From_Encapsulated_Lib => False,
Next => null); Next => null);
Imported := Project.Imported_Projects; Imported := Project.Imported_Projects;
else else
Imported.Next := new Project_List_Element' Imported.Next := new Project_List_Element'
(Project => New_Project, (Project => New_Project,
Next => null); From_Encapsulated_Lib => False,
Next => null);
Imported := Imported.Next; Imported := Imported.Next;
end if; end if;
end if; end if;
@ -2762,7 +2768,7 @@ package body Prj.Proc is
else else
declare declare
Imported : Project_List; Imported, Mark : Project_List;
Declaration_Node : Project_Node_Id := Empty_Node; Declaration_Node : Project_Node_Id := Empty_Node;
Name : constant Name_Id := Name : constant Name_Id :=
@ -2795,10 +2801,18 @@ package body Prj.Proc is
(Project_Qualifier_Of (Project_Qualifier_Of
(From_Project_Node, From_Project_Node_Tree))); (From_Project_Node, From_Project_Node_Tree)));
-- Note that at this point we do not know yet if the project has
-- been withed from an encapsulated library or not.
In_Tree.Projects := In_Tree.Projects :=
new Project_List_Element' new Project_List_Element'
(Project => Project, (Project => Project,
Next => In_Tree.Projects); From_Encapsulated_Lib => False,
Next => In_Tree.Projects);
-- Keep track of this point
Mark := In_Tree.Projects;
Processed_Projects.Set (Name, Project); Processed_Projects.Set (Name, Project);
@ -2874,7 +2888,8 @@ package body Prj.Proc is
(Declaration_Node, From_Project_Node_Tree), (Declaration_Node, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree, From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env, Env => Env,
Extended_By => Project); Extended_By => Project,
From_Encapsulated_Lib => From_Encapsulated_Lib);
Process_Declarative_Items Process_Declarative_Items
(Project => Project, (Project => Project,
@ -2893,29 +2908,57 @@ package body Prj.Proc is
Process_Imported_Projects (Imported, Limited_With => True); Process_Imported_Projects (Imported, Limited_With => True);
if Err_Vars.Total_Errors_Detected = 0 then -- At this point (after Process_Declarative_Items) we have the
Process_Aggregated_Projects; -- attribute values set, we can backtrace In_Tree.Project and
-- set the From_Encapsulated_Library status.
-- For an aggregate library we add the aggregated projects as declare
-- imported ones. This is necessary to give visibility to all Lib_Standalone : constant Prj.Variable_Value :=
-- sources from the aggregates from the aggregated library Prj.Util.Value_Of
-- projects. (Snames.Name_Library_Standalone,
Project.Decl.Attributes,
Shared);
List : Project_List := In_Tree.Projects;
Is_Encapsulated : Boolean;
begin
Get_Name_String (Lib_Standalone.Value);
To_Lower (Name_Buffer (1 .. Name_Len));
if Project.Qualifier = Aggregate_Library then Is_Encapsulated := Name_Buffer (1 .. Name_Len) = "encapsulated";
declare
L : Aggregated_Project_List; if Is_Encapsulated then
begin while List /= null and then List /= Mark loop
L := Project.Aggregated_Projects; List.From_Encapsulated_Lib := Is_Encapsulated;
while L /= null loop List := List.Next;
Project.Imported_Projects := end loop;
new Project_List_Element'
(Project => L.Project,
Next => Project.Imported_Projects);
L := L.Next;
end loop;
end;
end if; end if;
end if;
if Err_Vars.Total_Errors_Detected = 0 then
Process_Aggregated_Projects;
-- For an aggregate library we add the aggregated projects
-- as imported ones. This is necessary to give visibility
-- to all sources from the aggregates from the aggregated
-- library projects.
if Project.Qualifier = Aggregate_Library then
declare
L : Aggregated_Project_List;
begin
L := Project.Aggregated_Projects;
while L /= null loop
Project.Imported_Projects :=
new Project_List_Element'
(Project => L.Project,
From_Encapsulated_Lib => Is_Encapsulated,
Next =>
Project.Imported_Projects);
L := L.Next;
end loop;
end;
end if;
end if;
end;
if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then
Free (Child_Env); Free (Child_Env);

View File

@ -1477,9 +1477,10 @@ package body Prj is
Project : Project_Id; Project : Project_Id;
procedure Recursive_Add procedure Recursive_Add
(Prj : Project_Id; (Prj : Project_Id;
Tree : Project_Tree_Ref; Tree : Project_Tree_Ref;
Dummy : in out Boolean); Context : Project_Context;
Dummy : in out Boolean);
-- Recursively add the projects imported by project Project, but not -- Recursively add the projects imported by project Project, but not
-- those that are extended. -- those that are extended.
@ -1488,9 +1489,10 @@ package body Prj is
------------------- -------------------
procedure Recursive_Add procedure Recursive_Add
(Prj : Project_Id; (Prj : Project_Id;
Tree : Project_Tree_Ref; Tree : Project_Tree_Ref;
Dummy : in out Boolean) Context : Project_Context;
Dummy : in out Boolean)
is is
pragma Unreferenced (Dummy, Tree); pragma Unreferenced (Dummy, Tree);
@ -1521,13 +1523,14 @@ package body Prj is
Project.All_Imported_Projects := Project.All_Imported_Projects :=
new Project_List_Element' new Project_List_Element'
(Project => Prj2, (Project => Prj2,
Next => Project.All_Imported_Projects); From_Encapsulated_Lib => Context.From_Encapsulated_Lib,
Next => Project.All_Imported_Projects);
end if; end if;
end Recursive_Add; end Recursive_Add;
procedure For_All_Projects is procedure For_All_Projects is
new For_Every_Project_Imported (Boolean, Recursive_Add); new For_Every_Project_Imported_Context (Boolean, Recursive_Add);
Dummy : Boolean := False; Dummy : Boolean := False;
List : Project_List; List : Project_List;

View File

@ -938,8 +938,9 @@ package Prj is
type Project_List_Element; type Project_List_Element;
type Project_List is access all Project_List_Element; type Project_List is access all Project_List_Element;
type Project_List_Element is record type Project_List_Element is record
Project : Project_Id := No_Project; Project : Project_Id := No_Project;
Next : Project_List := null; From_Encapsulated_Lib : Boolean := False;
Next : Project_List := null;
end record; end record;
-- A list of projects -- A list of projects