]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: do not Set_Is_Imported on exception names
authorAlexandre Oliva <oliva@adacore.com>
Mon, 22 Sep 2025 16:11:12 +0000 (13:11 -0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 28 Oct 2025 10:24:06 +0000 (11:24 +0100)
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.

gcc/ada/sem_ch13.adb
gcc/ada/sem_prag.adb

index 779accbbd60b01a34993e891a5c1df917b04ef83..f7be890536d01a017f6b152e190f5fbac20fc3fb 100644 (file)
@@ -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
 
index 8d430516c04a743165661f7fd1d7e198b1f4ed2e..0dc2e4f56bf104ea7c966ec79c5e7d44a86f5532 100644 (file)
@@ -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