https://gcc.gnu.org/g:71828dce3e08cfbd82b3ac1f728ac119028946e0

commit r17-1207-g71828dce3e08cfbd82b3ac1f728ac119028946e0
Author: Marc Poulhiès <[email protected]>
Date:   Mon Apr 27 10:22:01 2026 +0200

    ada: Adjust expansion disabling for ghost expression functions
    
    When analyzing a Ghost expression function, expansion was disabled,
    which was an issue when some entities needed to be frozen (which is
    often the case as expression function are often the first freezing point
    of entities).
    
    The previous change:
    
     "Warn on unmodified parameters of expression functions"
    
    now triggers the disabling of the expander because it marks the body of
    expression function as "coming from source".
    
    This change adjust the disabling condition by excluding body coming from
    expression function.
    
    gcc/ada/ChangeLog:
    
            * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not disable
            expander if body comes from an expression function.

Diff:
---
 gcc/ada/sem_ch6.adb | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 568b7d46db67..fd12a5571087 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -3743,9 +3743,14 @@ package body Sem_Ch6 is
       --  user entities, as internally generated entitities might still need
       --  to be expanded (e.g. those generated for types).
 
+      --  Do not disable expansion if the body comes from an expression
+      --  function as they are often the first freezing point of entities and
+      --  expansion is needed to freeze them properly.
+
       if not CodePeer_Mode
         and then Present (Ghost_Config.Ignored_Ghost_Region)
         and then Comes_From_Source (Body_Id)
+        and then not From_Expression_Function
       then
          Expander_Active := False;
       end if;

Reply via email to