]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix crash on real literal in declare expression of expression function
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 20 May 2024 12:33:14 +0000 (14:33 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 4 Nov 2024 16:48:08 +0000 (17:48 +0100)
The problem is that the freeze node of the type to which the real literal
is resolved is placed inside the expression function instead of outside.

gcc/ada/

* freeze.adb (Freeze_Expression): Also attach pending freeze nodes
to the parent in the case of an internal block in a spec expression.

gcc/ada/freeze.adb

index d032b75f1f2d1f2fde5251c9250654e87434ff14..4c3c45d79752b719ab57a411db592d308e602ed8 100644 (file)
@@ -8701,7 +8701,8 @@ package body Freeze is
             end if;
 
             --  The current scope may be that of a constrained component of
-            --  an enclosing record declaration, or of a loop of an enclosing
+            --  an enclosing record declaration, or a block of an enclosing
+            --  declare expression in Ada 2022, or of a loop of an enclosing
             --  quantified expression or aggregate with an iterated component
             --  in Ada 2022, which is above the current scope in the scope
             --  stack. Indeed in the context of a quantified expression or
@@ -8713,7 +8714,7 @@ package body Freeze is
 
             if not Is_Compilation_Unit (Current_Scope)
               and then (Is_Record_Type (Scope (Current_Scope))
-                         or else (Ekind (Current_Scope) = E_Loop
+                         or else (Ekind (Current_Scope) in E_Block | E_Loop
                                    and then Is_Internal (Current_Scope)))
             then
                Pos := Pos - 1;