aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2020-01-08 17:36:43 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-03 06:01:36 -0400
commit075116992690d6f29530a0a7f08cf2f7d5652a93 (patch)
tree515fd8861fb5e68b21dad1773ddef0489dd39155 /gcc
parent0000998e65ce6109d351200bf8e896762932ec2e (diff)
downloadgcc-075116992690d6f29530a0a7f08cf2f7d5652a93.zip
gcc-075116992690d6f29530a0a7f08cf2f7d5652a93.tar.gz
gcc-075116992690d6f29530a0a7f08cf2f7d5652a93.tar.bz2
[Ada] Unnesting problems with expansion of Loop_Entry attribute
2020-06-03 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * exp_attr.adb (Expand_Loop_Entry_Attribute): Revise loop that resets the scopes of entities associated with Loop_Id to the scope of the new function, so the resetting is not restricted to itypes, but excludes loop parameters and the function entity itself. However, this fix is believed to be incomplete and a ??? comment is added to indicate that.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_attr.adb36
1 files changed, 25 insertions, 11 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 6c59ae0..939183c 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -1434,22 +1434,36 @@ package body Exp_Attr is
Insert_Action (Loop_Stmt, Func_Decl);
Pop_Scope;
- -- The analysis of the condition may have generated itypes
- -- that are now used within the function: Adjust their
- -- scopes accordingly so that their use appears in their
- -- scope of definition.
+ -- The analysis of the condition may have generated entities
+ -- (such as itypes) that are now used within the function.
+ -- Adjust their scopes accordingly so that their use appears
+ -- in their scope of definition.
declare
- Ityp : Entity_Id;
+ Ent : Entity_Id;
begin
- Ityp := First_Entity (Loop_Id);
-
- while Present (Ityp) loop
- if Is_Itype (Ityp) then
- Set_Scope (Ityp, Func_Id);
+ Ent := First_Entity (Loop_Id);
+
+ while Present (Ent) loop
+ -- Various entities that now occur within the function
+ -- need to have their scope reset, but not all entities
+ -- associated with Loop_Id are now inside the function.
+ -- The function entity itself and loop parameters can
+ -- be outside the function, and there may be others.
+ -- It's not clear how the determination of what entity
+ -- scopes need to be adjusted can be made accurately.
+ -- Perhaps it will be necessary to traverse the function
+ -- body to find the exact entities whose scopes need to
+ -- be reset to the function's Entity_Id. ???
+
+ if Ekind (Ent) /= E_Loop_Parameter
+ and then Ent /= Func_Id
+ then
+ Set_Scope (Ent, Func_Id);
end if;
- Next_Entity (Ityp);
+
+ Next_Entity (Ent);
end loop;
end;