[Ada] Fix crash on quantified expression in expression function
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 26 May 2020 10:55:26 +0000 (12:55 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 10 Jul 2020 09:16:17 +0000 (05:16 -0400)
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
gcc/ada/freeze.adb

index c2a2e14..8650542 100644 (file)
@@ -10969,6 +10969,7 @@ package body Einfo is
 
          when Type_Kind
             | E_Constant
+            | E_Loop_Parameter
             | E_Variable
          =>
             Write_Str ("Related_Expression");
index 4b58b75..6620ae3 100644 (file)
@@ -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