From: Piotr Trojanek <[email protected]>
Pragma Attach_Handler and Interrupt_Handler are only legal for procedures
declared in protected definition. When given for procedures declared in
protected body, they were wrongly accepted and triggered an odd error message
from expansion.
gcc/ada/ChangeLog:
* sem_prag.adb (Check_Interrupt_Or_Attach_Handler): Refine test for
protected procedures; fix typo in comment.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_prag.adb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index e73cdedb4f6..00b78d9632f 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -7023,12 +7023,14 @@ package body Sem_Prag is
Handler_Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
Proc_Scope := Scope (Handler_Proc);
- if Ekind (Proc_Scope) /= E_Protected_Type then
+ if Nkind (Parent (Subprogram_Spec (Handler_Proc))) /=
+ N_Protected_Definition
+ then
Error_Pragma_Arg
("argument of pragma% must be protected procedure", Arg1);
end if;
- -- For pragma case (as opposed to access case), check placement.
+ -- For pragma case (as opposed to aspect case), check placement.
-- We don't need to do that for aspects, because we have the
-- check that they aspect applies an appropriate procedure.
--
2.43.0