[COMMITTED,24/31] ada: Create a ghost region for pragma annotate

Message ID 20250911091904.1505690-24-poulhies@adacore.com
State Committed
Commit b69dbe06f91248457e7b532d5c8fffc4f73b1f76
Headers
Series [COMMITTED,01/31] ada: Disable new warning for composite equality ops that can raise Program_Error |

Commit Message

Marc Poulhiès Sept. 11, 2025, 9:18 a.m. UTC
  From: Viljar Indus <indus@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_prag.adb | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Patch

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 753ccda66756..661d4401d7a2 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -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;
 
          -------------------------------------------------