+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
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;
else
Cursor := Id;
- Set_Ekind (Cursor, E_Variable);
+ -- Set_Ekind (Cursor, E_Variable);
end if;
Iterator := Make_Temporary (Loc, 'I');
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Cursor, Loc),
Expression => Rhs));
+ Set_Assignment_OK (Name (Last (Stats)));
end;
-- Generate:
-- 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
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)
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) /
-- 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
+ if Present (Iter)
+ and then Present (Iterator_Specification (Iter))
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;
+
+ -- 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;