From f9c20bd7853a746b7c9373bff6b92459b53703cd Mon Sep 17 00:00:00 2001 From: Gary Dismukes Date: Wed, 26 Aug 2020 19:35:06 -0400 Subject: [PATCH] [Ada] Better error for illegal call to abstract operation in instantiations gcc/ada/ * sem_ch4.adb (Analyze_Call): In the case where the call is not overloaded, check for a call to an abstract nondispatching operation and flag an error. --- gcc/ada/sem_ch4.adb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 30c977f4eff..61c7b4c42d4 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -1254,6 +1254,25 @@ package body Sem_Ch4 is Analyze_One_Call (N, Nam_Ent, True, Success); + -- If the nonoverloaded interpretation is a call to an abstract + -- nondispatching operation, then flag an error and return. + + -- Should this be incorporated in Remove_Abstract_Operations (which + -- currently only deals with cases where the name is overloaded)? ??? + + if Is_Overloadable (Nam_Ent) + and then Is_Abstract_Subprogram (Nam_Ent) + and then not Is_Dispatching_Operation (Nam_Ent) + then + Set_Etype (N, Any_Type); + + Error_Msg_Sloc := Sloc (Nam_Ent); + Error_Msg_NE + ("cannot call abstract operation& declared#", N, Nam_Ent); + + return; + end if; + -- If this is an indirect call, the return type of the access_to -- subprogram may be an incomplete type. At the point of the call, -- use the full type if available, and at the same time update the -- 2.30.2