From: Ronan Desplanques Date: Wed, 21 Jan 2026 16:16:03 +0000 (+0100) Subject: ada: Fix exception on attaching non-handler procedure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5f6c3c0af8bebfc4b237c756ba2bc6114e4455a;p=thirdparty%2Fgcc.git 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 --git a/gcc/ada/libgnarl/s-interr.adb b/gcc/ada/libgnarl/s-interr.adb index be964c57407..47bcf6b2cb7 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