]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 21 Apr 2016 08:23:05 +0000 (10:23 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 21 Apr 2016 08:23:05 +0000 (10:23 +0200)
2016-04-21  Javier Miranda  <miranda@adacore.com>

* exp_util.adb (Build_Procedure_Form): No action needed for
subprogram renamings since the backend can generate the call
using the renamed subprogram. This leaves the tree more clean
to the backend.
* exp_ch6.adb (Expand_Call): Extend previous patch for
rewritten-for-c entities to handle subprogram renamings.
(Rewrite_Function_Call_For_C): Handle subprogram renamings.

2016-04-21  Ed Schonberg  <schonberg@adacore.com>

* sem_ch13.adb: Code cleanup.

From-SVN: r235307

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/exp_util.adb
gcc/ada/sem_ch13.adb

index 1383b3a959fc8692fbd33aee72905de4d1444941..c349a060dea4d5e8018ef28a0188204fe6af7075 100644 (file)
@@ -1,3 +1,17 @@
+2016-04-21  Javier Miranda  <miranda@adacore.com>
+
+       * exp_util.adb (Build_Procedure_Form): No action needed for
+       subprogram renamings since the backend can generate the call
+       using the renamed subprogram. This leaves the tree more clean
+       to the backend.
+       * exp_ch6.adb (Expand_Call): Extend previous patch for
+       rewritten-for-c entities to handle subprogram renamings.
+       (Rewrite_Function_Call_For_C): Handle subprogram renamings.
+
+2016-04-21  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch13.adb: Code cleanup.
+
 2016-04-21  Ed Schonberg  <schonberg@adacore.com>
 
        * sem_ch6.adb (Analyze_Subprogram_Body_Helper): If the body is
index 4dcd4e9d8a62fa45acf47efab397d6d03cd7698a..d084c3791235bc45d354f44c63349a27c9462f89 100644 (file)
@@ -703,10 +703,18 @@ package body Exp_Ch6 is
                                   New_Occurrence_Of (Param_Id, Loc),
                                 Expression =>
                                   New_Occurrence_Of (Ret_Obj, Sloc (Stmt)));
-                  Stmts   : constant List_Id :=
-                              Statements (Handled_Statement_Sequence (Stmt));
+                  Stmts   : List_Id;
 
                begin
+                  --  The extended return may just contain the declaration.
+
+                  if Present (Handled_Statement_Sequence (Stmt)) then
+                     Stmts :=  Statements (Handled_Statement_Sequence (Stmt));
+
+                  else
+                     Stmts := New_List;
+                  end if;
+
                   Set_Assignment_OK (Name (Assign));
 
                   Rewrite (Stmt,
@@ -715,8 +723,7 @@ package body Exp_Ch6 is
                         Return_Object_Declarations (Stmt),
                       Handled_Statement_Sequence =>
                         Make_Handled_Sequence_Of_Statements (Loc,
-                          Statements =>
-                            Statements (Handled_Statement_Sequence (Stmt)))));
+                          Statements => Stmts)));
 
                   Replace_Returns (Param_Id, Stmts);
 
@@ -2682,7 +2689,7 @@ package body Exp_Ch6 is
       if Modify_Tree_For_C
         and then Nkind (Call_Node) = N_Function_Call
         and then Is_Entity_Name (Name (Call_Node))
-        and then Rewritten_For_C (Entity (Name (Call_Node)))
+        and then Rewritten_For_C (Ultimate_Alias (Entity (Name (Call_Node))))
       then
          --  For internally generated calls ensure that they reference the
          --  entity of the spec of the called function (needed since the
@@ -2690,11 +2697,14 @@ package body Exp_Ch6 is
          --  See for example Expand_Boolean_Operator().
 
          if not (Comes_From_Source (Call_Node))
-           and then Nkind (Unit_Declaration_Node (Entity (Name (Call_Node))))
+           and then Nkind
+                      (Unit_Declaration_Node
+                        (Ultimate_Alias (Entity (Name (Call_Node)))))
                       = N_Subprogram_Body
          then
             Set_Entity (Name (Call_Node),
-              Rewritten_For_C_Func_Id (Entity (Name (Call_Node))));
+              Rewritten_For_C_Func_Id
+                (Ultimate_Alias (Entity (Name (Call_Node)))));
          end if;
 
          Rewrite_Function_Call_For_C (Call_Node);
@@ -8419,7 +8429,7 @@ package body Exp_Ch6 is
 
       --  Local variables
 
-      Func_Id     : constant Entity_Id  := Entity (Name (N));
+      Func_Id     : constant Entity_Id  := Ultimate_Alias (Entity (Name (N)));
       Par         : constant Node_Id    := Parent (N);
       Proc_Id     : constant Entity_Id  := Rewritten_For_C_Proc_Id (Func_Id);
       Loc         : constant Source_Ptr := Sloc (Par);
index 13773faa915e8c22829914019fdcb7ee0c658673..190a1dcd6b086001cdb1e3e2a297ca12778a0efa 100644 (file)
@@ -932,9 +932,12 @@ package body Exp_Util is
       Proc_Decl    : Node_Id;
 
    begin
-      --  No action needed if this transformation was already done
+      --  No action needed if this transformation was already done or in case
+      --  of subprogram renaming declarations
 
-      if Nkind (Specification (N)) = N_Procedure_Specification then
+      if Nkind (Specification (N)) = N_Procedure_Specification
+        or else Nkind (N) = N_Subprogram_Renaming_Declaration
+      then
          return;
       end if;
 
index 777964e2d3d0e267aefb4a4e3bf7c20a69a78b22..352742aeae33712d3e2171076cb1943b8ac96b11 100644 (file)
@@ -12613,7 +12613,7 @@ package body Sem_Ch13 is
             if Nkind (Prefix (N)) = N_Identifier
               and then Chars (Prefix (N)) /= Chars (E)
             then
-               Find_Selected_Component (Parent (N));
+               Find_Selected_Component (N);
             end if;
 
             return Skip;