[Ada] Fix insertion of declaration inside quantified expression
authorYannick Moy <moy@adacore.com>
Fri, 18 Mar 2022 16:33:25 +0000 (17:33 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 17 May 2022 08:25:47 +0000 (08:25 +0000)
When the evaluation of the subtype_indication for the
iterator_specification of a quantified_expression leads to the insertion
of a type declaration, this should be done with Insert_Action instead of
Insert_Before.

gcc/ada/

* sem_ch5.adb (Analyze_Iterator_Specification): Use
Insert_Action when possibly inside an expression.

gcc/ada/sem_ch5.adb

index 633e5c7..e6d34c3 100644 (file)
@@ -2316,7 +2316,7 @@ package body Sem_Ch5 is
                           Defining_Identifier => S,
                           Subtype_Indication  => New_Copy_Tree (Subt));
             begin
-               Insert_Before (Parent (Parent (N)), Decl);
+               Insert_Action (N, Decl);
                Analyze (Decl);
                Rewrite (Subt, New_Occurrence_Of (S, Sloc (Subt)));
             end;