[Ada] Fix insertion of declaration inside quantified expression

Message ID 20220517082749.GA1090214@adacore.com
State Committed
Commit 5c44da007b4a2fbf55d1ca86e456abf3789b50fd
Headers
Series [Ada] Fix insertion of declaration inside quantified expression |

Commit Message

Pierre-Marie de Rodat May 17, 2022, 8:27 a.m. UTC
  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.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

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

Patch

diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -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;