https://gcc.gnu.org/g:24640ef86eaef114c59cc66fa283ce39c960a4f8

commit r16-8988-g24640ef86eaef114c59cc66fa283ce39c960a4f8
Author: Ronan Desplanques <[email protected]>
Date:   Wed Jan 21 17:16:03 2026 +0100

    ada: Fix exception on attaching non-handler procedure
    
    Before this patch, the program error raised when Attach_Handler was
    called on a procedure without Interrupt_Handler specified was
    accompanied by a message that related to a completely different error.
    This patch fixes this.
    
    gcc/ada/ChangeLog:
    
            * libgnarl/s-interr.adb (Unprotected_Exchange_Handler): Fix
            exception message.

Diff:
---
 gcc/ada/libgnarl/s-interr.adb | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/gcc/ada/libgnarl/s-interr.adb b/gcc/ada/libgnarl/s-interr.adb
index be964c574077..47bcf6b2cb72 100644
--- a/gcc/ada/libgnarl/s-interr.adb
+++ b/gcc/ada/libgnarl/s-interr.adb
@@ -861,21 +861,23 @@ package body System.Interrupts is
          --  We don't check anything if Restoration is True, since we may be
          --  detaching a static handler to restore a dynamic one.
 
-         if not Restoration and then not Static
-
+         if not Restoration and then not Static then
             --  Tries to overwrite a static Interrupt Handler with a dynamic
             --  Handler
+            if User_Handler (Interrupt).Static then
+               raise Program_Error
+                 with
+                   "trying to overwrite a static Interrupt Handler with a "
+                   & "dynamic handler";
+            end if;
 
-           and then (User_Handler (Interrupt).Static
-
-                       --  The new handler is not specified as an
-                       --  Interrupt Handler by a pragma.
-
-                       or else not Is_Registered (New_Handler))
-         then
-            raise Program_Error with
-              "trying to overwrite a static Interrupt Handler with a " &
-              "dynamic handler";
+            --  The new handler is not specified as an interrupt handler by an
+            --  aspect (see the second sentence of RM C.3.2 (17/3)).
+            if not Is_Registered (New_Handler) then
+               raise Program_Error
+                 with
+                   "trying to attach procedure without " & "Interrupt_Handler";
+            end if;
          end if;
 
          --  The interrupt should no longer be ignored if

Reply via email to