aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2020-03-23 17:44:29 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-12 04:29:23 -0400
commit3ca9a460f02fc538d314682f456bf3519f311f97 (patch)
tree78a59b4eb6b69fcb9cc3340d4de4b79ba2715345 /gcc/ada
parent019e90494bd07f71380547ad8c2c70826aaf88f9 (diff)
downloadgcc-3ca9a460f02fc538d314682f456bf3519f311f97.zip
gcc-3ca9a460f02fc538d314682f456bf3519f311f97.tar.gz
gcc-3ca9a460f02fc538d314682f456bf3519f311f97.tar.bz2
[Ada] Diagnose illegal overriding indicators in protected bodies
2020-06-12 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch6.adb (Check_Overriding_Indicatior): Reject an overriding indicator on a subprogram declared within a protected body.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/sem_ch6.adb13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 9fb46d9..5062f57 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -6515,6 +6515,19 @@ package body Sem_Ch6 is
return;
end if;
+ -- An overriding indication is illegal on a subprogram declared
+ -- in a protected body, where there is no operation to override.
+
+ if (Must_Override (Spec) or else Must_Not_Override (Spec))
+ and then Is_List_Member (Decl)
+ and then Present (Parent (List_Containing (Decl)))
+ and then Nkind (Parent (List_Containing (Decl))) = N_Protected_Body
+ then
+ Error_Msg_N
+ ("illegal overriding indication in protected body", Decl);
+ return;
+ end if;
+
-- The overriding operation is type conformant with the overridden one,
-- but the names of the formals are not required to match. If the names
-- appear permuted in the overriding operation, this is a possible