aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2024-06-13 15:28:29 -0700
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-07-02 15:20:35 +0200
commit404f1f7ddda79ce7a1fe1c4010f88e49ed50596e (patch)
tree5514b9bf5782ac8e891f5085c977c168512aefe6 /gcc/ada
parent15d3f36f76bda1720555b7f426957951d4e3b76d (diff)
downloadgcc-404f1f7ddda79ce7a1fe1c4010f88e49ed50596e.zip
gcc-404f1f7ddda79ce7a1fe1c4010f88e49ed50596e.tar.gz
gcc-404f1f7ddda79ce7a1fe1c4010f88e49ed50596e.tar.bz2
ada: Use clause (or use type clause) in a protected operation sometimes ignored.
In some cases, a use clause (or a use type clause) occurring within a protected operation is incorrectly ignored. gcc/ada/ * exp_ch9.adb (Expand_N_Protected_Body): Declare new procedure Unanalyze_Use_Clauses and call it before analyzing the newly constructed subprogram body.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/exp_ch9.adb41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index a8c7059..939a8e2 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -8316,6 +8316,11 @@ package body Exp_Ch9 is
-- <protected-procedure-name>P (Param1 .. ParamN);
-- end <protected-procedure-name>
+ procedure Unanalyze_Use_Clauses (Op_Body : Node_Id);
+ -- Use and Use_Type clauses in the tree rooted at Op_Body
+ -- that have already been analyzed need to be marked as unanalyzed
+ -- because otherwise they will be ineffective in their new context.
+
---------------------------------------
-- Build_Dispatching_Subprogram_Body --
---------------------------------------
@@ -8377,6 +8382,31 @@ package body Exp_Ch9 is
Make_Handled_Sequence_Of_Statements (Loc, Stmts));
end Build_Dispatching_Subprogram_Body;
+ ---------------------------
+ -- Unanalyze_Use_Clauses --
+ ---------------------------
+
+ procedure Unanalyze_Use_Clauses (Op_Body : Node_Id) is
+
+ function Process_One_Node (N : Node_Id) return Traverse_Result;
+ -- If N is a use or use type node then unanalyze it.
+
+ procedure Process_Tree is new Traverse_Proc (Process_One_Node);
+
+ function Process_One_Node (N : Node_Id) return Traverse_Result is
+ begin
+ if Nkind (N) in N_Use_Package_Clause | N_Use_Type_Clause then
+ Set_Analyzed (N, False);
+ end if;
+ return OK; -- return Skip if Is_Analyzed (N) ?
+ end Process_One_Node;
+
+ -- Start of processing for Analyze_Use_Clauses
+
+ begin
+ Process_Tree (Op_Body);
+ end Unanalyze_Use_Clauses;
+
-- Start of processing for Expand_N_Protected_Body
begin
@@ -8426,6 +8456,17 @@ package body Exp_Ch9 is
Build_Unprotected_Subprogram_Body (Op_Body, Pid);
end if;
+ -- Ugly.
+ -- We are going to perform name resolution in analysis of
+ -- this new body, but any already-analyzed use clauses
+ -- will be ineffective in this new context unless we take
+ -- action to "reactivate" them. So that's what we do here.
+ -- We arguably shouldn't be performing name resolution
+ -- here (just like we shouldn't perform name resolution in
+ -- an expanded instance body), but that's a larger issue.
+
+ Unanalyze_Use_Clauses (New_Op_Body);
+
Insert_After (Current_Node, New_Op_Body);
Current_Node := New_Op_Body;
Analyze (New_Op_Body);