From a042b9c6809a23bfb71676646a8c28b1e8e1249f Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 26 May 2020 12:55:26 +0200 Subject: [PATCH] [Ada] Fix crash on quantified expression in expression function gcc/ada/ * einfo.adb (Write_Field24_Name): Handle E_Loop_Parameter. * freeze.adb (Freeze_Expr_Types): Freeze the iterator type used as Default_Iterator of the name of an N_Iterator_Specification node. --- gcc/ada/einfo.adb | 1 + gcc/ada/freeze.adb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb index c2a2e14d41b..86505422f8a 100644 --- a/gcc/ada/einfo.adb +++ b/gcc/ada/einfo.adb @@ -10969,6 +10969,7 @@ package body Einfo is when Type_Kind | E_Constant + | E_Loop_Parameter | E_Variable => Write_Str ("Related_Expression"); diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 4b58b756b1c..6620ae3da30 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7990,6 +7990,22 @@ package body Freeze is and then Nkind (Parent (Node)) = N_Explicit_Dereference then Check_And_Freeze_Type (Designated_Type (Etype (Node))); + + -- An iterator specification freezes the iterator type, even though + -- that type is not attached to an entity in the construct. + + elsif Nkind (Node) in N_Has_Etype + and then Nkind (Parent (Node)) = N_Iterator_Specification + and then Node = Name (Parent (Node)) + then + declare + Iter : constant Node_Id := + Find_Aspect (Etype (Node), Aspect_Default_Iterator); + begin + if Present (Iter) then + Check_And_Freeze_Type (Etype (Expression (Iter))); + end if; + end; end if; -- No point in posting several errors on the same expression -- 2.30.2