aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2019-12-12 10:02:38 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-12-12 10:02:38 +0000
commit182c8b7d2d43c71c92736bc37fe2a17545aa7776 (patch)
tree25b8f7441ac3dd6e8750a6c7d59f94f54e400879
parentc171199011ac0d37df67ff99ea7286fa3455efcf (diff)
downloadgcc-182c8b7d2d43c71c92736bc37fe2a17545aa7776.zip
gcc-182c8b7d2d43c71c92736bc37fe2a17545aa7776.tar.gz
gcc-182c8b7d2d43c71c92736bc37fe2a17545aa7776.tar.bz2
[Ada] Handling up-level references in protected entries and freeze nodes
2019-12-12 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * exp_ch9.adb (Build_Protected_Entry): Analyze the block created to hold the declarations and statements of the protected entry body right after it's created, and then call Reset_Scopes_To on that block to reset the Scope of nested entities to the block scope. (Reset_Scope): Add handling for N_Freeze_Entity nodes, calling Reset_Scopes recursively on the Actions of such nodes. Also, for subprogram bodies that are encountered that might not have a separate declaration (such as type init procedures), reset the Scope of the subprogram's entity. From-SVN: r279289
-rw-r--r--gcc/ada/ChangeLog13
-rw-r--r--gcc/ada/exp_ch9.adb29
2 files changed, 42 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 9e271ac..f28fa45 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,16 @@
+2019-12-12 Gary Dismukes <dismukes@adacore.com>
+
+ * exp_ch9.adb (Build_Protected_Entry): Analyze the block created
+ to hold the declarations and statements of the protected entry
+ body right after it's created, and then call Reset_Scopes_To on
+ that block to reset the Scope of nested entities to the block
+ scope.
+ (Reset_Scope): Add handling for N_Freeze_Entity nodes, calling
+ Reset_Scopes recursively on the Actions of such nodes. Also, for
+ subprogram bodies that are encountered that might not have a
+ separate declaration (such as type init procedures), reset the
+ Scope of the subprogram's entity.
+
2019-12-12 Justin Squirek <squirek@adacore.com>
* sem_attr.adb (Analyze_Attribute): Add error message for
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index 720c1a9..6e34de1 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -48,6 +48,7 @@ with Rident; use Rident;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
+with Sem_Ch5; use Sem_Ch5;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8;
with Sem_Ch9; use Sem_Ch9;
@@ -3722,6 +3723,14 @@ package body Exp_Ch9 is
Declarations => Decls,
Handled_Statement_Sequence => Handled_Statement_Sequence (N)));
+ -- Analyze now and reset scopes for declarations so that Scope fields
+ -- currently denoting the entry will now denote the block scope.
+
+ Analyze_Statements (Bod_Stmts);
+
+ Reset_Scopes_To
+ (First (Bod_Stmts), Entity (Identifier (First (Bod_Stmts))));
+
case Corresponding_Runtime_Package (Pid) is
when System_Tasking_Protected_Objects_Entries =>
Append_To (Bod_Stmts,
@@ -14977,7 +14986,27 @@ package body Exp_Ch9 is
Next (Decl);
end loop;
+ elsif Nkind (N) = N_Freeze_Entity then
+
+ -- Scan the actions associated with a freeze node, which may
+ -- actually be declarations with entities that need to have
+ -- their scopes reset.
+
+ Decl := First (Actions (N));
+ while Present (Decl) loop
+ Reset_Scopes (Decl);
+ Next (Decl);
+ end loop;
+
elsif N /= Bod and then Nkind (N) in N_Proper_Body then
+
+ -- A subprogram without a separate declaration may be encountered,
+ -- and we need to reset the subprogram's entity's scope.
+
+ if Nkind (N) = N_Subprogram_Body then
+ Set_Scope (Defining_Entity (Specification (N)), E);
+ end if;
+
return Skip;
end if;