From 7d3a9f399afb2c6c00dbbc8c2538d18faacba13a Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Thu, 28 May 2020 17:09:32 -0400 Subject: [PATCH] [Ada] Spurious error on parameterless acccess_to_subprogram gcc/ada/ * exp_ch3.adb (Build_Access_Subprogram_Wrapper_Body): Create a proper signature when the access type denotes a parameterless subprogram. * exp_ch6.adb (Expand_Call): Handle properly a parameterless indirect call when the corresponding access type has contracts. --- gcc/ada/exp_ch3.adb | 2 +- gcc/ada/exp_ch6.adb | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 3402a087b6c5..705da5804d47 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -547,10 +547,10 @@ package body Exp_Ch3 is Act := First (Parameter_Specifications (Spec_Node)); while Present (Act) loop + exit when Act = Last (Parameter_Specifications (Spec_Node)); Append_To (Actuals, Make_Identifier (Loc, Chars (Defining_Identifier (Act)))); Next (Act); - exit when Act = Last (Parameter_Specifications (Spec_Node)); end loop; Ptr := diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 076bbbae0de0..a42bd25709dd 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -2686,9 +2686,10 @@ package body Exp_Ch6 is Access_Subprogram_Wrapper (Etype (Name (N))); Ptr : constant Node_Id := Prefix (Name (N)); Ptr_Type : constant Entity_Id := Etype (Ptr); - Parms : constant List_Id := Parameter_Associations (N); Typ : constant Entity_Id := Etype (N); + New_N : Node_Id; + Parms : List_Id := Parameter_Associations (N); Ptr_Act : Node_Id; begin @@ -2711,6 +2712,12 @@ package body Exp_Ch6 is Ptr_Act := Ptr; end if; + -- Handle parameterless subprogram. + + if No (Parms) then + Parms := New_List; + end if; + Append (Make_Parameter_Association (Loc, Selector_Name => Make_Identifier (Loc, -- 2.47.2