]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Create a ghost region for pragma annotate
authorViljar Indus <indus@adacore.com>
Fri, 22 Aug 2025 08:31:56 +0000 (11:31 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 11 Sep 2025 09:10:49 +0000 (11:10 +0200)
Create a ghost region for pragma annotate so that we are able to analyze
the entity references correctly inside the pragma.

gcc/ada/ChangeLog:

* sem_prag.adb: Create a ghost region for pragma annotate before
analyzing its arguments.

gcc/ada/sem_prag.adb

index 753ccda66756f5c2b680db9ed723cb427a4498a8..661d4401d7a2660701efba409f660ac33eaafc56 100644 (file)
@@ -14149,6 +14149,9 @@ package body Sem_Prag is
             Expr    : Node_Id;
             Nam_Arg : Node_Id;
 
+            Saved_Ghost_Config : constant Ghost_Config_Type := Ghost_Config;
+            --  Save the Ghost-related attributes to restore on exit
+
             --------------------------
             -- Inferred_String_Type --
             --------------------------
@@ -14226,6 +14229,10 @@ package body Sem_Prag is
                end if;
             end if;
 
+            --  Set the ghost mode before analyzing all of the arguments
+
+            Set_Ghost_Mode (N);
+
             --  Continue the processing with last argument removed for now
 
             Check_Arg_Is_Identifier (Arg1);
@@ -14271,6 +14278,8 @@ package body Sem_Prag is
                   Next (Arg);
                end loop;
             end if;
+
+            Restore_Ghost_Region (Saved_Ghost_Config);
          end Annotate;
 
          -------------------------------------------------