]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix exception on attaching non-handler procedure
authorRonan Desplanques <desplanques@adacore.com>
Wed, 21 Jan 2026 16:16:03 +0000 (17:16 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 26 May 2026 08:38:16 +0000 (10:38 +0200)
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.

gcc/ada/libgnarl/s-interr.adb

index be964c5740778a68a5e359fe79e5c19f2b81839d..47bcf6b2cb728d1410077491e8f5d94fea97c0db 100644 (file)
@@ -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