From d79e7af5ff74c714b15d0cd123752cc4714e4dc6 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 16 Nov 2020 18:10:25 +0100 Subject: [Ada] Transform_Function_Array issues gcc/ada/ * exp_ch6.adb (Build_Procedure_Body_Form): Adjust, the declaration of the procedure form is now insert before the original function body rather than after. (Expand_N_Subprogram_Declaration): Deal with private types whose full views are arrays. * exp_unst.adb (Unnest_Subprogram): Deal with private types. (Needs_Fat_Pointer): Code cleanup. * freeze.adb (Freeze_Subprogram): Ditto. * exp_util.adb (Build_Procedure_Form): Insert the procedure form decl before and not after. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Build missing spec when needed for Transform_Function_Array. * sem_util.adb (Get_Fullest_View): Deal with null entity. --- gcc/ada/exp_ch6.adb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'gcc/ada/exp_ch6.adb') diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 955049f..0a5fbcc 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -883,9 +883,8 @@ package body Exp_Ch6 is is Loc : constant Source_Ptr := Sloc (Func_Body); - Proc_Decl : constant Node_Id := - Next (Unit_Declaration_Node (Func_Id)); - -- It is assumed that the next node following the declaration of the + Proc_Decl : constant Node_Id := Prev (Unit_Declaration_Node (Func_Id)); + -- It is assumed that the node before the declaration of the -- corresponding subprogram spec is the declaration of the procedure -- form. @@ -6571,6 +6570,7 @@ package body Exp_Ch6 is Prot_Bod : Node_Id; Prot_Decl : Node_Id; Prot_Id : Entity_Id; + Typ : Entity_Id; begin -- Deal with case of protected subprogram. Do not generate protected @@ -6645,10 +6645,12 @@ package body Exp_Ch6 is -- are not needed by the C generator (and this also produces cleaner -- output). + Typ := Get_Fullest_View (Etype (Subp)); + if Transform_Function_Array and then Nkind (Specification (N)) = N_Function_Specification - and then Is_Array_Type (Etype (Subp)) - and then Is_Constrained (Etype (Subp)) + and then Is_Array_Type (Typ) + and then Is_Constrained (Typ) and then not Is_Unchecked_Conversion_Instance (Subp) then Build_Procedure_Form (N); -- cgit v1.1