aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-08-04 12:06:32 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-08-04 12:06:32 +0200
commit8f4a8befc8801bc1e0259f43eea1f28bbdcf673d (patch)
treebb09752881459e1e36bad9c6d7dec0935e1d881a /gcc/ada
parente7a45277aa2ed5b30f96ac55bf9c1de47cb36f95 (diff)
downloadgcc-8f4a8befc8801bc1e0259f43eea1f28bbdcf673d.zip
gcc-8f4a8befc8801bc1e0259f43eea1f28bbdcf673d.tar.gz
gcc-8f4a8befc8801bc1e0259f43eea1f28bbdcf673d.tar.bz2
[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
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog18
-rw-r--r--gcc/ada/exp_ch5.adb9
-rw-r--r--gcc/ada/exp_util.adb6
-rw-r--r--gcc/ada/s-fatgen.adb2
-rw-r--r--gcc/ada/sem_ch5.adb32
5 files changed, 55 insertions, 12 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 960102e..5db6af9 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 120200f..591e1d3 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -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
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 9467154..bfba403 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -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)
diff --git a/gcc/ada/s-fatgen.adb b/gcc/ada/s-fatgen.adb
index 1f4c498..b5cd9f5 100644
--- a/gcc/ada/s-fatgen.adb
+++ b/gcc/ada/s-fatgen.adb
@@ -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) /
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 65a000f..8552a7ca 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -3114,25 +3114,39 @@ 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
+ 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;