aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-08-07 09:13:08 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-21 03:22:49 -0400
commit4270e94541bb865334849677b7c887c7eceb8353 (patch)
tree47abf7e08f3d502222afe3289387eb3db5445c0e /gcc/ada
parenta5476382a7f9a9732b1c0095cbd9cbc3ecd99edb (diff)
downloadgcc-4270e94541bb865334849677b7c887c7eceb8353.zip
gcc-4270e94541bb865334849677b7c887c7eceb8353.tar.gz
gcc-4270e94541bb865334849677b7c887c7eceb8353.tar.bz2
[Ada] Fix analysis of iterated component expression with null range
gcc/ada/ * exp_aggr.adb (Gen_Loop): Analyze copy of the expression in the scope of the implicit loop with name of the index parameter visible.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/exp_aggr.adb26
1 files changed, 25 insertions, 1 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index bbb4f88..6c274a2 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -53,6 +53,7 @@ with Sem; use Sem;
with Sem_Aggr; use Sem_Aggr;
with Sem_Aux; use Sem_Aux;
with Sem_Ch3; use Sem_Ch3;
+with Sem_Ch8; use Sem_Ch8;
with Sem_Ch13; use Sem_Ch13;
with Sem_Eval; use Sem_Eval;
with Sem_Mech; use Sem_Mech;
@@ -1954,7 +1955,30 @@ package body Exp_Aggr is
Expander_Mode_Save_And_Set (False);
Tcopy := New_Copy_Tree (Expr);
Set_Parent (Tcopy, N);
- Analyze_And_Resolve (Tcopy, Component_Type (Etype (N)));
+
+ -- For iterated_component_association analyze and resolve
+ -- the expression with name of the index parameter visible.
+ -- To manipulate scopes, we use entity of the implicit loop.
+
+ if Is_Iterated_Component then
+ declare
+ Index_Parameter : constant Entity_Id :=
+ Defining_Identifier (Parent (Expr));
+ begin
+ Push_Scope (Scope (Index_Parameter));
+ Enter_Name (Index_Parameter);
+ Analyze_And_Resolve
+ (Tcopy, Component_Type (Etype (N)));
+ End_Scope;
+ end;
+
+ -- For ordinary component association, just analyze and
+ -- resolve the expression.
+
+ else
+ Analyze_And_Resolve (Tcopy, Component_Type (Etype (N)));
+ end if;
+
Expander_Mode_Restore;
end if;
end if;