Commit b0159fbe by Arnaud Charlet

[multiple changes]

2009-07-11  Thomas Quinot  <quinot@adacore.com>

	* sem_util.adb, sem_res.adb, sem_warn.adb: Minor comment editing:
	Lvalue -> lvalue

	* exp_ch6.adb: Minor reformatting

2009-07-11  Ed Schonberg  <schonberg@adacore.com>

	* freeze.adb (Expand_Atomic_Aggregate): Clean up code, take into
	account possible type qualification to determine whether aggregate
	needs a target temporary to respect atomic type or object.

	* exp_aggr.adb (Expand_Record_Aggregate): Use new version of
	Expand_Atomic_Aggregate.

2009-07-11  Emmanuel Briot  <briot@adacore.com>

	* prj.adb, prj.ads, prj-nmsc.adb (Mark_Excluded_Sources): Speed up
	algorithm.
	(Excluded_Sources_Htable): No longer a global table.
	Change error message to indicate which files are illegal in the list
	of excluded files, as opposed to only the location in the project
	file.
	(Find_Source): New subprogram.

From-SVN: r149515
parent 3e3a9a6a
2009-07-11 Thomas Quinot <quinot@adacore.com>
* sem_util.adb, sem_res.adb, sem_warn.adb: Minor comment editing:
Lvalue -> lvalue
* exp_ch6.adb: Minor reformatting
2009-07-11 Ed Schonberg <schonberg@adacore.com>
* freeze.adb (Expand_Atomic_Aggregate): Clean up code, take into
account possible type qualification to determine whether aggregate
needs a target temporary to respect atomic type or object.
* exp_aggr.adb (Expand_Record_Aggregate): Use new version of
Expand_Atomic_Aggregate.
2009-07-11 Emmanuel Briot <briot@adacore.com>
* prj.adb, prj.ads, prj-nmsc.adb (Mark_Excluded_Sources): Speed up
algorithm.
(Excluded_Sources_Htable): No longer a global table.
Change error message to indicate which files are illegal in the list
of excluded files, as opposed to only the location in the project
file.
(Find_Source): New subprogram.
2009-07-10 Thomas Quinot <quinot@adacore.com> 2009-07-10 Thomas Quinot <quinot@adacore.com>
* exp_ch7.adb: Update comments. * exp_ch7.adb: Update comments.
......
...@@ -5475,11 +5475,9 @@ package body Exp_Aggr is ...@@ -5475,11 +5475,9 @@ package body Exp_Aggr is
-- an atomic move for it. -- an atomic move for it.
if Is_Atomic (Typ) if Is_Atomic (Typ)
and then Nkind_In (Parent (N), N_Object_Declaration,
N_Assignment_Statement)
and then Comes_From_Source (Parent (N)) and then Comes_From_Source (Parent (N))
and then Expand_Atomic_Aggregate (N, Typ)
then then
Expand_Atomic_Aggregate (N, Typ);
return; return;
-- No special management required for aggregates used to initialize -- No special management required for aggregates used to initialize
......
...@@ -1146,7 +1146,7 @@ package body Exp_Ch6 is ...@@ -1146,7 +1146,7 @@ package body Exp_Ch6 is
-- resulting variable is a temporary which does not designate -- resulting variable is a temporary which does not designate
-- the proper out-parameter, which may not be addressable. In -- the proper out-parameter, which may not be addressable. In
-- that case, generate an assignment to the original expression -- that case, generate an assignment to the original expression
-- (before expansion of the packed reference) so that the proper -- (before expansion of the packed reference) so that the proper
-- expansion of assignment to a packed component can take place. -- expansion of assignment to a packed component can take place.
declare declare
...@@ -4661,7 +4661,7 @@ package body Exp_Ch6 is ...@@ -4661,7 +4661,7 @@ package body Exp_Ch6 is
end if; end if;
-- Analyze and resolve the new call. The actuals have already been -- Analyze and resolve the new call. The actuals have already been
-- resolved, but expansion of a function call will add extra actuals -- resolved, but expansion of a function call will add extra actuals
-- if needed. Analysis of a procedure call already includes resolution. -- if needed. Analysis of a procedure call already includes resolution.
Analyze (N); Analyze (N);
......
...@@ -1115,15 +1115,27 @@ package body Freeze is ...@@ -1115,15 +1115,27 @@ package body Freeze is
-- Expand_Atomic_Aggregate -- -- Expand_Atomic_Aggregate --
----------------------------- -----------------------------
procedure Expand_Atomic_Aggregate (E : Entity_Id; Typ : Entity_Id) is function Expand_Atomic_Aggregate
(E : Entity_Id;
Typ : Entity_Id) return Boolean
is
Loc : constant Source_Ptr := Sloc (E); Loc : constant Source_Ptr := Sloc (E);
New_N : Node_Id; New_N : Node_Id;
Par : Node_Id;
Temp : Entity_Id; Temp : Entity_Id;
begin begin
if (Nkind (Parent (E)) = N_Object_Declaration Par := Parent (E);
or else Nkind (Parent (E)) = N_Assignment_Statement)
and then Comes_From_Source (Parent (E)) -- Array may be qualified, so find outer context.
if Nkind (Par) = N_Qualified_Expression then
Par := Parent (Par);
end if;
if (Nkind (Par) = N_Object_Declaration
or else Nkind (Par) = N_Assignment_Statement)
and then Comes_From_Source (Par)
then then
Temp := Temp :=
Make_Defining_Identifier (Loc, Make_Defining_Identifier (Loc,
...@@ -1134,11 +1146,14 @@ package body Freeze is ...@@ -1134,11 +1146,14 @@ package body Freeze is
Defining_Identifier => Temp, Defining_Identifier => Temp,
Object_Definition => New_Occurrence_Of (Typ, Loc), Object_Definition => New_Occurrence_Of (Typ, Loc),
Expression => Relocate_Node (E)); Expression => Relocate_Node (E));
Insert_Before (Parent (E), New_N); Insert_Before (Par, New_N);
Analyze (New_N); Analyze (New_N);
Set_Expression (Parent (E), New_Occurrence_Of (Temp, Loc)); Set_Expression (Par, New_Occurrence_Of (Temp, Loc));
return True;
else
return False;
end if; end if;
end Expand_Atomic_Aggregate; end Expand_Atomic_Aggregate;
...@@ -2351,8 +2366,10 @@ package body Freeze is ...@@ -2351,8 +2366,10 @@ package body Freeze is
and then Nkind (Parent (E)) = N_Object_Declaration and then Nkind (Parent (E)) = N_Object_Declaration
and then Present (Expression (Parent (E))) and then Present (Expression (Parent (E)))
and then Nkind (Expression (Parent (E))) = N_Aggregate and then Nkind (Expression (Parent (E))) = N_Aggregate
and then
Expand_Atomic_Aggregate (Expression (Parent (E)), Etype (E))
then then
Expand_Atomic_Aggregate (Expression (Parent (E)), Etype (E)); null;
end if; end if;
-- For a subprogram, freeze all parameter types and also the return -- For a subprogram, freeze all parameter types and also the return
......
...@@ -175,12 +175,17 @@ package Freeze is ...@@ -175,12 +175,17 @@ package Freeze is
-- do not allow a size clause if the size would not otherwise be known at -- do not allow a size clause if the size would not otherwise be known at
-- compile time in any case. -- compile time in any case.
procedure Expand_Atomic_Aggregate (E : Entity_Id; Typ : Entity_Id); function Expand_Atomic_Aggregate
(E : Entity_Id;
Typ : Entity_Id) return Boolean;
-- If an atomic object is initialized with an aggregate or is assigned -- If an atomic object is initialized with an aggregate or is assigned
-- an aggregate, we have to prevent a piecemeal access or assignment -- an aggregate, we have to prevent a piecemeal access or assignment
-- to the object, even if the aggregate is to be expanded. We create -- to the object, even if the aggregate is to be expanded. We create
-- a temporary for the aggregate, and assign the temporary instead, -- a temporary for the aggregate, and assign the temporary instead,
-- so that the back end can generate an atomic move for it. -- so that the back end can generate an atomic move for it. This is
-- only done in the context of an object declaration or an assignment.
-- Function is a noop and returns false in other contexts.
function Freeze_Entity (E : Entity_Id; Loc : Source_Ptr) return List_Id; function Freeze_Entity (E : Entity_Id; Loc : Source_Ptr) return List_Id;
-- Freeze an entity, and return Freeze nodes, to be inserted at the -- Freeze an entity, and return Freeze nodes, to be inserted at the
......
...@@ -469,6 +469,52 @@ package body Prj is ...@@ -469,6 +469,52 @@ package body Prj is
Reset (Seen); Reset (Seen);
end For_Every_Project_Imported; end For_Every_Project_Imported;
-----------------
-- Find_Source --
-----------------
function Find_Source
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
In_Imported_Only : Boolean;
Base_Name : File_Name_Type) return Source_Id
is
Result : Source_Id := No_Source;
procedure Look_For_Sources (Proj : Project_Id; Src : in out Source_Id);
-- Look for Base_Name in the sources of Proj
procedure Look_For_Sources (Proj : Project_Id; Src : in out Source_Id) is
Iterator : Source_Iterator;
begin
Iterator := For_Each_Source (In_Tree => In_Tree, Project => Proj);
while Element (Iterator) /= No_Source loop
if Element (Iterator).File = Base_Name then
Src := Element (Iterator);
return;
end if;
Next (Iterator);
end loop;
end Look_For_Sources;
procedure For_Imported_Projects is new For_Every_Project_Imported
(State => Source_Id, Action => Look_For_Sources);
begin
if In_Imported_Only then
Look_For_Sources (Project, Result);
if Result = No_Source then
For_Imported_Projects
(By => Project,
With_State => Result);
end if;
else
Look_For_Sources (No_Project, Result);
end if;
return Result;
end Find_Source;
-------------- --------------
-- Get_Mode -- -- Get_Mode --
-------------- --------------
......
...@@ -1295,6 +1295,15 @@ package Prj is ...@@ -1295,6 +1295,15 @@ package Prj is
procedure Next (Iter : in out Source_Iterator); procedure Next (Iter : in out Source_Iterator);
-- Move on to the next source -- Move on to the next source
function Find_Source
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
In_Imported_Only : Boolean;
Base_Name : File_Name_Type) return Source_Id;
-- Find the first source file with the given name either in the whole tree
-- (if In_Imported_Only is False) or in the projects imported or extended
-- by Project otherwise.
----------------------- -----------------------
-- Project_Tree_Data -- -- Project_Tree_Data --
----------------------- -----------------------
......
...@@ -7600,7 +7600,7 @@ package body Sem_Res is ...@@ -7600,7 +7600,7 @@ package body Sem_Res is
-- Generate cross-reference. We needed to wait until full overloading -- Generate cross-reference. We needed to wait until full overloading
-- resolution was complete to do this, since otherwise we can't tell if -- resolution was complete to do this, since otherwise we can't tell if
-- we are an Lvalue of not. -- we are an lvalue of not.
if May_Be_Lvalue (N) then if May_Be_Lvalue (N) then
Generate_Reference (Entity (S), S, 'm'); Generate_Reference (Entity (S), S, 'm');
......
...@@ -7155,7 +7155,7 @@ package body Sem_Util is ...@@ -7155,7 +7155,7 @@ package body Sem_Util is
when N_Assignment_Statement => when N_Assignment_Statement =>
return N = Name (P); return N = Name (P);
-- Function call arguments are never Lvalues -- Function call arguments are never lvalues
when N_Function_Call => when N_Function_Call =>
return False; return False;
...@@ -7241,7 +7241,7 @@ package body Sem_Util is ...@@ -7241,7 +7241,7 @@ package body Sem_Util is
end; end;
-- Test for appearing in a conversion that itself appears -- Test for appearing in a conversion that itself appears
-- in an Lvalue context, since this should be an Lvalue. -- in an lvalue context, since this should be an lvalue.
when N_Type_Conversion => when N_Type_Conversion =>
return Known_To_Be_Assigned (P); return Known_To_Be_Assigned (P);
...@@ -7276,8 +7276,8 @@ package body Sem_Util is ...@@ -7276,8 +7276,8 @@ package body Sem_Util is
return N = Prefix (P) return N = Prefix (P)
and then Name_Implies_Lvalue_Prefix (Attribute_Name (P)); and then Name_Implies_Lvalue_Prefix (Attribute_Name (P));
-- For an expanded name, the name is an Lvalue if the expanded name -- For an expanded name, the name is an lvalue if the expanded name
-- is an Lvalue, but the prefix is never an Lvalue, since it is just -- is an lvalue, but the prefix is never an lvalue, since it is just
-- the scope where the name is found. -- the scope where the name is found.
when N_Expanded_Name => when N_Expanded_Name =>
...@@ -7287,11 +7287,11 @@ package body Sem_Util is ...@@ -7287,11 +7287,11 @@ package body Sem_Util is
return False; return False;
end if; end if;
-- For a selected component A.B, A is certainly an Lvalue if A.B is -- For a selected component A.B, A is certainly an lvalue if A.B is.
-- an Lvalue. B is a little interesting, if we have A.B:=3, there is -- B is a little interesting, if we have A.B := 3, there is some
-- some discussion as to whether B is an Lvalue or not, we choose to -- discussion as to whether B is an lvalue or not, we choose to say
-- say it is. Note however that A is not an Lvalue if it is of an -- it is. Note however that A is not an lvalue if it is of an access
-- access type since this is an implicit dereference. -- type since this is an implicit dereference.
when N_Selected_Component => when N_Selected_Component =>
if N = Prefix (P) if N = Prefix (P)
...@@ -7304,8 +7304,8 @@ package body Sem_Util is ...@@ -7304,8 +7304,8 @@ package body Sem_Util is
end if; end if;
-- For an indexed component or slice, the index or slice bounds is -- For an indexed component or slice, the index or slice bounds is
-- never an Lvalue. The prefix is an Lvalue if the indexed component -- never an lvalue. The prefix is an lvalue if the indexed component
-- or slice is an Lvalue, except if it is an access type, where we -- or slice is an lvalue, except if it is an access type, where we
-- have an implicit dereference. -- have an implicit dereference.
when N_Indexed_Component => when N_Indexed_Component =>
...@@ -7317,17 +7317,17 @@ package body Sem_Util is ...@@ -7317,17 +7317,17 @@ package body Sem_Util is
return May_Be_Lvalue (P); return May_Be_Lvalue (P);
end if; end if;
-- Prefix of a reference is an Lvalue if the reference is an Lvalue -- Prefix of a reference is an lvalue if the reference is an lvalue
when N_Reference => when N_Reference =>
return May_Be_Lvalue (P); return May_Be_Lvalue (P);
-- Prefix of explicit dereference is never an Lvalue -- Prefix of explicit dereference is never an lvalue
when N_Explicit_Dereference => when N_Explicit_Dereference =>
return False; return False;
-- Function call arguments are never Lvalues -- Function call arguments are never lvalues
when N_Function_Call => when N_Function_Call =>
return False; return False;
...@@ -7414,7 +7414,7 @@ package body Sem_Util is ...@@ -7414,7 +7414,7 @@ package body Sem_Util is
end; end;
-- Test for appearing in a conversion that itself appears in an -- Test for appearing in a conversion that itself appears in an
-- Lvalue context, since this should be an Lvalue. -- lvalue context, since this should be an lvalue.
when N_Type_Conversion => when N_Type_Conversion =>
return May_Be_Lvalue (P); return May_Be_Lvalue (P);
...@@ -7424,7 +7424,7 @@ package body Sem_Util is ...@@ -7424,7 +7424,7 @@ package body Sem_Util is
when N_Object_Renaming_Declaration => when N_Object_Renaming_Declaration =>
return True; return True;
-- All other references are definitely not Lvalues -- All other references are definitely not lvalues
when others => when others =>
return False; return False;
......
...@@ -475,7 +475,7 @@ package body Sem_Warn is ...@@ -475,7 +475,7 @@ package body Sem_Warn is
and then Present (Entity (N)) and then Present (Entity (N))
and then Entity (N) = Var and then Entity (N) = Var
then then
-- If this is an Lvalue, then definitely abandon, since -- If this is an lvalue, then definitely abandon, since
-- this could be a direct modification of the variable. -- this could be a direct modification of the variable.
if May_Be_Lvalue (N) then if May_Be_Lvalue (N) then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment