Processing of index parameters in iterated_component_association was
different within array aggregates (where we created a synonym
identifier) and array delta aggregates (where we used the existing
defining identifier). Apparently, we can use the existing defining
identifiers in both cases.
This change is needed to handle iterated_component_association in
GNATprove, where a custom expansion of iterated_component_association
must analyze its expression (because the GNAT will only analyze a copy
of this expression for legality checking and then rely on its own
expansion with proper analysis). With an (anonymous) synonym
identifier, which was not attached to AST, it was not possible to access
the scope entity introduced by GNAT resolution.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_aggr.adb (Resolve_Iterated_Component_Association): Use
existing defining identifier for index parameter.
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -1640,21 +1640,16 @@ package body Sem_Aggr is
Set_Etype (Ent, Standard_Void_Type);
Set_Parent (Ent, Parent (N));
Push_Scope (Ent);
- Id :=
- Make_Defining_Identifier (Loc,
- Chars => Chars (Defining_Identifier (N)));
-- Insert and decorate the index variable in the current scope.
-- The expression has to be analyzed once the index variable is
- -- directly visible. Mark the variable as referenced to prevent
- -- spurious warnings, given that subsequent uses of its name in the
- -- expression will reference the internal (synonym) loop variable.
+ -- directly visible.
+ Id := Defining_Identifier (N);
Enter_Name (Id);
Set_Etype (Id, Index_Typ);
Set_Ekind (Id, E_Variable);
Set_Scope (Id, Ent);
- Set_Referenced (Id);
-- Analyze a copy of the expression, to verify legality. We use
-- a copy because the expression will be analyzed anew when the