https://gcc.gnu.org/g:9f88ab6a60cf0222fba4952acff022f3cc5b9ff3
commit r16-4690-g9f88ab6a60cf0222fba4952acff022f3cc5b9ff3 Author: Alexandre Oliva <[email protected]> Date: Mon Sep 22 13:11:12 2025 -0300 ada: do not Set_Is_Imported on exception names Exception names don't get the Is_Imported flag set even when they're imported from CPP. With the flag set, we end up referencing an external variable instead of defining the exception data structure as expected, and aspect Import behaves differently from pragma Import. Refrain from calling Set_Is_Imported when analyzing an exception's Import aspect. gcc/ada/ChangeLog: * sem_ch13.adb (Analyze_Aspect_Export_Import): Skip Set_Is_Imported on E_Exception. * sem_prag.adb (Process_Import_Or_Interface): Explain why not Set_Is_Imported. Diff: --- gcc/ada/sem_ch13.adb | 8 +++++++- gcc/ada/sem_prag.adb | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 779accbbd60b..f7be890536d0 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -2372,7 +2372,13 @@ package body Sem_Ch13 is then if A_Id = Aspect_Import then Set_Has_Completion (E); - Set_Is_Imported (E); + + -- Do not set Is_Imported on Exceptions, similarly + -- to Sem_Prag.Process_Import_Or_Interface. + + if Ekind (E) /= E_Exception then + Set_Is_Imported (E); + end if; -- An imported object cannot be explicitly initialized diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 8d430516c04a..0dc2e4f56bf1 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -10699,6 +10699,9 @@ package body Sem_Prag is -- the External_Name). For exceptions, the External_Name is the -- name of the RTTI structure. + -- Do not call Set_Is_Imported as that would disable the output + -- of the needed exception data structures. + -- ??? Emit an error if pragma Import/Export_Exception is present elsif Nkind (Parent (Def_Id)) = N_Incomplete_Type_Declaration then
