diff mbox series

[COMMITTED,20/30] ada: Fix crash on real literal in declare expression of expression function

Message ID 20240620085321.2412421-20-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/30] ada: Fix list of attributes defined by Ada 2022 | expand

Commit Message

Marc Poulhiès June 20, 2024, 8:53 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

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.

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

---
 gcc/ada/freeze.adb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 3c3d038c392..1867880b314 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8872,7 +8872,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
@@ -8884,7 +8885,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;