[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 4 Aug 2014 10:06:32 +0000 (12:06 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 4 Aug 2014 10:06:32 +0000 (12:06 +0200)
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

gcc/ada/ChangeLog
gcc/ada/exp_ch5.adb
gcc/ada/exp_util.adb
gcc/ada/s-fatgen.adb
gcc/ada/sem_ch5.adb

index 960102e22e800aa8529ef09f6988222d79627ebd..5db6af9fe446ad32e07ed9f098794eae3985e55b 100644 (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
index 120200f891541f4e09998f707871c734ce1ca036..591e1d3d56c825517fe78e2e37d75d7d2d613fc4 100644 (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
index 9467154cfdaecdd148541b4d4b406122d847a60c..bfba40331d8be2b2e13b8886bfd6af4ab5fecf35 100644 (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)
index 1f4c49857624b99c861b6420dbd780ca4cb63675..b5cd9f56266736477fca5d6420b6b2f7fb580a12 100644 (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) /
index 65a000f6da8400cb33109896ccce3c362490be30..8552a7caaa0d1cb07867d64120f2b7633b5d93b4 100644 (file)
@@ -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;