[multiple changes]

2014-08-04  Thomas Quinot  <quinot@adacore.com>

	* s-fatgen.adb: Minor reformatting.

2014-08-04  Arnaud Charlet  <charlet@adacore.com>

	* exp_util.adb (Is_Possibly_Unaligned_Object): Always return
	False on .NET.

2014-08-04  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch5.adb (Analyze_Loop_Statement): Set properly the kind of
	the loop parameter for element iterators over containers and
	arrays, so that improper uses of it are detected in the loop
	body when expansion is disabled.
	* exp_ch5.adb (Expand_Iterator_Loop): The entity kind of the
	generated cursor is that of the analyzed loop parameter.

From-SVN: r213558
This commit is contained in:
Arnaud Charlet 2014-08-04 12:06:32 +02:00
parent e7a45277aa
commit 8f4a8befc8
5 changed files with 55 additions and 12 deletions

View File

@ -1,3 +1,21 @@
2014-08-04 Thomas Quinot <quinot@adacore.com>
* s-fatgen.adb: Minor reformatting.
2014-08-04 Arnaud Charlet <charlet@adacore.com>
* exp_util.adb (Is_Possibly_Unaligned_Object): Always return
False on .NET.
2014-08-04 Ed Schonberg <schonberg@adacore.com>
* sem_ch5.adb (Analyze_Loop_Statement): Set properly the kind of
the loop parameter for element iterators over containers and
arrays, so that improper uses of it are detected in the loop
body when expansion is disabled.
* exp_ch5.adb (Expand_Iterator_Loop): The entity kind of the
generated cursor is that of the analyzed loop parameter.
2014-08-04 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch3.adb (Build_CPP_Init_Procedure): Remove

View File

@ -3200,6 +3200,7 @@ package body Exp_Ch5 is
Container : constant Node_Id := Name (I_Spec);
Container_Typ : constant Entity_Id := Base_Type (Etype (Container));
I_Kind : constant Entity_Kind := Ekind (Id);
Cursor : Entity_Id;
Iterator : Entity_Id;
New_Loop : Node_Id;
@ -3481,7 +3482,7 @@ package body Exp_Ch5 is
else
Cursor := Id;
Set_Ekind (Cursor, E_Variable);
-- Set_Ekind (Cursor, E_Variable);
end if;
Iterator := Make_Temporary (Loc, 'I');
@ -3527,6 +3528,7 @@ package body Exp_Ch5 is
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Cursor, Loc),
Expression => Rhs));
Set_Assignment_OK (Name (Last (Stats)));
end;
-- Generate:
@ -3592,12 +3594,15 @@ package body Exp_Ch5 is
-- The cursor is only modified in expanded code, so it appears
-- as unassigned to the warning machinery. We must suppress
-- this spurious warning explicitly.
-- this spurious warning explicitly. The cursor's kind is that of
-- the original loop parameter (it is a constant if the doamin of
-- iteration is constant).
Set_Warnings_Off (Cursor);
Set_Assignment_OK (Decl);
Insert_Action (N, Decl);
Set_Ekind (Cursor, I_Kind);
end;
-- If the range of iteration is given by a function call that

View File

@ -5146,6 +5146,12 @@ package body Exp_Util is
T : constant Entity_Id := Etype (N);
begin
-- Objects are never unaligned on VMs
if VM_Target /= No_VM then
return False;
end if;
-- If renamed object, apply test to underlying object
if Is_Entity_Name (N)

View File

@ -892,7 +892,7 @@ package body System.Fat_Gen is
for R'Address use XA;
-- R is a view of the input floating-point parameter. Note that we
-- must avoid copying the actual bits of this parameter in float
-- form (since it may be a signalling NaN.
-- form (since it may be a signalling NaN).
E : constant IEEE_Exponent_Range :=
Integer ((R (Most_Significant_Word) and Exponent_Mask) /

View File

@ -3114,24 +3114,38 @@ package body Sem_Ch5 is
-- If the expander is not active, or in SPARK mode, then we want to
-- analyze the loop body now even in the Ada 2012 iterator case, since
-- the rewriting will not be done. Insert the loop variable in the
-- current scope, if not done when analysing the iteration scheme.
-- current scope, if not done when analysing the iteration scheme. Set
-- is kind properly to detect improper uses in the loop body.
if No (Iter)
or else No (Iterator_Specification (Iter))
or else not Expander_Active
then
if Present (Iter)
and then Present (Iterator_Specification (Iter))
then
if not Expander_Active then
declare
Id : constant Entity_Id :=
Defining_Identifier (Iterator_Specification (Iter));
I_Spec : constant Node_Id := Iterator_Specification (Iter);
Id : constant Entity_Id := Defining_Identifier (I_Spec);
begin
if Scope (Id) /= Current_Scope then
Enter_Name (Id);
end if;
end;
-- In an element iterator, The loop parameter is a variable if
-- the domain of iteration (container or array) is a variable.
if not Of_Present (I_Spec)
or else not Is_Variable (Name (I_Spec))
then
Set_Ekind (Id, E_Loop_Parameter);
end if;
end;
Analyze_Statements (Statements (N));
end if;
else
-- Pre-Ada2012 for-loops and while loops.
Analyze_Statements (Statements (N));
end if;