diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-10-16 09:05:55 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-11-04 16:57:58 +0100 |
commit | 7bcfdac0ef763587efd014310b779e192b143c62 (patch) | |
tree | 6ed56decb659aa953276f1b421cb093198d27289 /gcc | |
parent | 56ea463808d47cc8bf342b32125e793cfcde472d (diff) | |
download | gcc-7bcfdac0ef763587efd014310b779e192b143c62.zip gcc-7bcfdac0ef763587efd014310b779e192b143c62.tar.gz gcc-7bcfdac0ef763587efd014310b779e192b143c62.tar.bz2 |
ada: Fix crash on default value with nested iterated component associations
The problem is that the freeze node for the type of the element ends up in
the component list of the record type declared with the default value.
gcc/ada/ChangeLog:
PR ada/113036
* freeze.adb (Freeze_Expression): Deal with freezing actions coming
from within nested internal loops present in spec expressions.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/freeze.adb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 9a86217..7502a04 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -9055,8 +9055,9 @@ package body Freeze is or else Ekind (Current_Scope) = E_Void then declare - Freeze_Nodes : List_Id := No_List; - Pos : Int := Scope_Stack.Last; + Freeze_Nodes : List_Id := No_List; + Pos : Int := Scope_Stack.Last; + Scop : Entity_Id := Current_Scope; begin if Present (Desig_Typ) then @@ -9083,12 +9084,18 @@ package body Freeze is -- 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 (Ekind (Current_Scope) in E_Block | E_Loop - and then Is_Internal (Current_Scope))) - then - Pos := Pos - 1; + if not Is_Compilation_Unit (Scop) then + if Is_Record_Type (Scope (Scop)) then + Pos := Pos - 1; + + else + while Ekind (Scop) in E_Block | E_Loop + and then Is_Internal (Scop) + loop + Pos := Pos - 1; + Scop := Scope (Scop); + end loop; + end if; end if; if Is_Non_Empty_List (Freeze_Nodes) then |