]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Avoid ghost context errors when preanalyzing Loop_Invariant
authorViljar Indus <indus@adacore.com>
Tue, 2 Sep 2025 12:20:54 +0000 (15:20 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 15 Sep 2025 12:59:33 +0000 (14:59 +0200)
gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pragma): Disable context checks for
the preanalysis of the expression for Loop_Invariant pragmas
as the ghost region for the pragma has not been set up yet.

gcc/ada/sem_prag.adb

index b1fefa8a29729b1846d08610e978ae66b1d07e73..f75f1f7eb4d18e3ebdbc525fadc18d9ffaea544f 100644 (file)
@@ -14455,9 +14455,15 @@ package body Sem_Prag is
 
                --  Perform preanalysis to deal with embedded Loop_Entry
                --  attributes.
+               --
+               --  But ignore the ghost context checks for now. The expression
+               --  will be reanalyzed with the correct ghost region once the
+               --  pragma has been converted to pragma check.
 
+               Ghost_Context_Checks_Disabled := True;
                Preanalyze_And_Resolve_Assert_Expression
                   (Arg_Check, Any_Boolean);
+               Ghost_Context_Checks_Disabled := False;
             end if;
 
             --  Implement Assert[_And_Cut]/Assume/Loop_Invariant by generating