In cases involving instantiations and formal packages, a call to an
abstract nondispatching subprogram within an instantiation, where
the operation comes in via the actual for a formal package, was
not being flagged with an informative message on the instantiation.
(A program could potentially compile but end up with an undefined
reference at link time, or a general error might be flagged on
the instantiation without anything more specific.) This is corrected
by checking during analysis for such a call in the case where the call
is not overloaded with multiple interpretations, and issuing an error
at that point.

Tested on x86_64-pc-linux-gnu, committed on trunk

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.
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
--- 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


Reply via email to