* [COMMITTED] ada: Fix crash on iterated component in expression function
@ 2023-05-16 8:41 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-05-16 8:41 UTC (permalink / raw)
To: gcc-patches; +Cc: Eric Botcazou
From: Eric Botcazou <ebotcazou@adacore.com>
The problem is that the freeze node generated for the type of a static
subexpression present in the expression function is incorrectly placed
inside instead of outside the function.
gcc/ada/
* freeze.adb (Freeze_Expression): When the freezing is to be done
outside the current scope, skip any scope that is an internal loop.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/freeze.adb | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 86622003b97..f54ae0503a1 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8712,17 +8712,19 @@ package body Freeze is
-- The current scope may be that of a constrained component of
-- an enclosing record declaration, or of a loop of an enclosing
- -- quantified expression, which is above the current scope in the
- -- scope stack. Indeed in the context of a quantified expression,
- -- a scope is created and pushed above the current scope in order
- -- to emulate the loop-like behavior of the quantified expression.
+ -- 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
+ -- an aggregate with an iterated component, an internal scope is
+ -- created and pushed above the current scope in order to emulate
+ -- the loop-like behavior of the construct.
-- If the expression is within a top-level pragma, as for a pre-
-- condition on a library-level subprogram, nothing to do.
if not Is_Compilation_Unit (Current_Scope)
and then (Is_Record_Type (Scope (Current_Scope))
- or else Nkind (Parent (Current_Scope)) =
- N_Quantified_Expression)
+ or else (Ekind (Current_Scope) = E_Loop
+ and then Is_Internal (Current_Scope)))
then
Pos := Pos - 1;
end if;
--
2.40.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-16 8:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 8:41 [COMMITTED] ada: Fix crash on iterated component in expression function Marc Poulhiès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).