diff options
author | Gary Dismukes <dismukes@adacore.com> | 2020-08-26 19:35:06 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-10-23 04:24:46 -0400 |
commit | f9c20bd7853a746b7c9373bff6b92459b53703cd (patch) | |
tree | 6d8f4ef850154030ca9c26fdc298dc5bfec1e427 /gcc/ada | |
parent | ca5d8b907298d5818127ead3f0d5a628e5f5dcc3 (diff) | |
download | gcc-f9c20bd7853a746b7c9373bff6b92459b53703cd.zip gcc-f9c20bd7853a746b7c9373bff6b92459b53703cd.tar.gz gcc-f9c20bd7853a746b7c9373bff6b92459b53703cd.tar.bz2 |
[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.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 30c977f..61c7b4c 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 |