summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog14
-rw-r--r--gcc/ada/exp_ch6.adb26
-rw-r--r--gcc/ada/exp_util.adb7
-rw-r--r--gcc/ada/sem_ch13.adb2
4 files changed, 38 insertions, 11 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 1383b3a959f..c349a060dea 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 4dcd4e9d8a6..d084c379123 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -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);
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 13773faa915..190a1dcd6b0 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -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;
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 777964e2d3d..352742aeae3 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -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;