[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 28 Apr 2017 13:48:59 +0000 (15:48 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 28 Apr 2017 13:48:59 +0000 (15:48 +0200)
2017-04-28  Ed Schonberg  <schonberg@adacore.com>

* sem_ch4.adb (Complete_Object_Operation): When rewriting the
controlling actual in a prefixed call, preserve the original node
information if the prefix itself has been rewritten, for ASIS use.

2017-04-28  Hristian Kirtchev  <kirtchev@adacore.com>

* exp_ch6.adb (Insert_Post_Call_Actions):
Code clean up. Insert the post-call actions after an enclosing
procedure call when N denotes a function call and appears as an
actual parameter in the procedure call.

2017-04-28  Eric Botcazou  <ebotcazou@adacore.com>

* freeze.adb (Check_Component_Storage_Order): If there is a clause
for the component, also reject the attribute if the component
doesn't end on a byte boundary and its scalar storage order is
different from that of the enclosing record type.

From-SVN: r247391

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/freeze.adb
gcc/ada/sem_ch4.adb

index 1ad8fbf..d433c51 100644 (file)
@@ -1,3 +1,23 @@
+2017-04-28  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch4.adb (Complete_Object_Operation): When rewriting the
+       controlling actual in a prefixed call, preserve the original node
+       information if the prefix itself has been rewritten, for ASIS use.
+
+2017-04-28  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * exp_ch6.adb (Insert_Post_Call_Actions):
+       Code clean up. Insert the post-call actions after an enclosing
+       procedure call when N denotes a function call and appears as an
+       actual parameter in the procedure call.
+
+2017-04-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * freeze.adb (Check_Component_Storage_Order): If there is a clause
+       for the component, also reject the attribute if the component
+       doesn't end on a byte boundary and its scalar storage order is
+       different from that of the enclosing record type.
+
 2017-04-28  Javier Miranda  <miranda@adacore.com>
 
        * atree.ads (Info_Messages): Removed.
index 36f4360..0317dc3 100644 (file)
@@ -7316,6 +7316,8 @@ package body Exp_Ch6 is
    ------------------------------
 
    procedure Insert_Post_Call_Actions (N : Node_Id; Post_Call : List_Id) is
+      Context : constant Node_Id := Parent (N);
+
    begin
       if Is_Empty_List (Post_Call) then
          return;
@@ -7326,7 +7328,7 @@ package body Exp_Ch6 is
       --  call or indexing, i.e. an expression context as well.
 
       if not Is_List_Member (N)
-        or else Nkind_In (Parent (N), N_Function_Call, N_Indexed_Component)
+        or else Nkind_In (Context, N_Function_Call, N_Indexed_Component)
       then
          --  In Ada 2012 the call may be a function call in an expression
          --  (since OUT and IN OUT parameters are now allowed for such calls).
@@ -7402,23 +7404,27 @@ package body Exp_Ch6 is
          --  corresponding statement list.
 
          else
-            declare
-               P : Node_Id;
-
-            begin
-               P := Parent (N);
-               pragma Assert (Nkind_In (P, N_Entry_Call_Alternative,
-                                           N_Triggering_Alternative));
+            pragma Assert (Nkind_In (Context, N_Entry_Call_Alternative,
+                                              N_Triggering_Alternative));
 
-               if Is_Non_Empty_List (Statements (P)) then
-                  Insert_List_Before_And_Analyze
-                    (First (Statements (P)), Post_Call);
-               else
-                  Set_Statements (P, Post_Call);
-               end if;
-            end;
+            if Is_Non_Empty_List (Statements (Context)) then
+               Insert_List_Before_And_Analyze
+                 (First (Statements (Context)), Post_Call);
+            else
+               Set_Statements (Context, Post_Call);
+            end if;
          end if;
 
+      --  A procedure call is always part of a declarative or statement list,
+      --  however a function call may appear nested within a construct. Most
+      --  cases of function call nesting are handled in the special case above.
+      --  The only exception is when the function call acts as an actual in a
+      --  procedure call. In this case the function call is in a list, but the
+      --  post-call actions must be inserted after the procedure call.
+
+      elsif Nkind (Context) = N_Procedure_Call_Statement then
+         Insert_Actions_After (Context, Post_Call);
+
       --  Otherwise, normal case where N is in a statement sequence, just put
       --  the post-call stuff after the call statement.
 
index 5abbe39..9c48644 100644 (file)
@@ -1175,7 +1175,7 @@ package body Freeze is
 
       Comp_Byte_Aligned : Boolean;
       pragma Warnings (Off, Comp_Byte_Aligned);
-      --  Set for the record case, True if Comp starts on a byte boundary
+      --  Set for the record case, True if Comp is aligned on byte boundaries
       --  (in which case it is allowed to have different storage order).
 
       Comp_SSO_Differs  : Boolean;
@@ -1195,12 +1195,14 @@ package body Freeze is
 
          else
             --  If a component clause is present, check if the component starts
-            --  on a storage element boundary. Otherwise conservatively assume
-            --  it does so only in the case where the record is not packed.
+            --  and ends on byte boundaries. Otherwise conservatively assume it
+            --  does so only in the case where the record is not packed.
 
             if Present (Component_Clause (Comp)) then
                Comp_Byte_Aligned :=
-                 Normalized_First_Bit (Comp) mod System_Storage_Unit = 0;
+                 (Normalized_First_Bit (Comp) mod System_Storage_Unit = 0)
+                   and then
+                 (Esize (Comp) mod System_Storage_Unit = 0);
             else
                Comp_Byte_Aligned := not Is_Packed (Encl_Type);
             end if;
index a7362a7..4f2c1fd 100644 (file)
@@ -8621,6 +8621,14 @@ package body Sem_Ch4 is
          Actuals : List_Id;
 
       begin
+         --  Obj may already have been rewritten if it involves an implicit
+         --  dereference (e.g. if it is an access to a limited view). Preserve
+         --  a link to the original node for ASIS use.
+
+         if not Comes_From_Source (Obj) then
+            Set_Original_Node (Dummy, Original_Node (Obj));
+         end if;
+
          --  Common case covering 1) Call to a procedure and 2) Call to a
          --  function that has some additional actuals.