From dcaabdd2daa7fefd24985cc3de5b0752c920df69 Mon Sep 17 00:00:00 2001 From: Viljar Indus Date: Thu, 28 Aug 2025 13:18:39 +0300 Subject: [PATCH] ada: Avoid ghost context check in early freeze We freeze the expression for expression functions that complete before we have set up the ghost region from both the existing spec and body. Avoid triggering the ghost context checks during the analysis for this early freeze as the expression will be reanalyzed when we analyze the new function body created for the expression function. gcc/ada/ChangeLog: * sem_ch6.adb (Analyze_Expression_Function): Disable ghost checks during the early freeze. --- gcc/ada/sem_ch6.adb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 9042b3378ce..4e5ede6b429 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -436,11 +436,20 @@ package body Sem_Ch6 is Set_Parent (New_Body, Parent (N)); + -- Disable Ghost checks for this early analysis on the expression. + -- We have not analyzed the new body of the expression function + -- yet so the ghost region is not set up properly for the ghost + -- context checks yet. Avoid the checks for now as the expression + -- will be re-analyzed when the expression function is replaced + -- with the function body. + + Ghost_Context_Checks_Disabled := True; Freeze_Expr_Types (Def_Id => Def_Id, Typ => Typ, Expr => Expr, N => N); + Ghost_Context_Checks_Disabled := False; end if; -- For navigation purposes, indicate that the function is a body -- 2.47.3