From: Alexandre Oliva <[email protected]>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
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 779accbbd60..f7be890536d 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 8d430516c04..0dc2e4f56bf 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
--
2.51.0