aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2020-05-22 15:29:57 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-08 10:55:55 -0400
commitd387808d8bd4e6eda08dd5f1661c1c70a6c9a1b2 (patch)
tree32f03c0c948b135e89b0597fda1233fcb4de22e4 /gcc
parenteafbde5131d2926fdc48b1c663d03865c9a37302 (diff)
downloadgcc-d387808d8bd4e6eda08dd5f1661c1c70a6c9a1b2.zip
gcc-d387808d8bd4e6eda08dd5f1661c1c70a6c9a1b2.tar.gz
gcc-d387808d8bd4e6eda08dd5f1661c1c70a6c9a1b2.tar.bz2
[Ada] Fix recent regression on _Master declaration
gcc/ada/ * exp_ch9.adb (Build_Class_Wide_Master): Insert the declaration of _Master before its use; required to avoid assertion failure in the backend.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_ch9.adb13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index 70fdf1d..c4b9882 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -1215,10 +1215,21 @@ package body Exp_Ch9 is
if not Has_Master_Entity (Master_Scope)
or else No (Current_Entity_In_Scope (Name_Id))
then
+ declare
+ Ins_Nod : Node_Id;
+
begin
Set_Has_Master_Entity (Master_Scope);
Master_Decl := Build_Master_Declaration (Loc);
- Insert_Action (Find_Hook_Context (Related_Node), Master_Decl);
+
+ -- Ensure that the master declaration is placed before its use
+
+ Ins_Nod := Find_Hook_Context (Related_Node);
+ while not Is_List_Member (Ins_Nod) loop
+ Ins_Nod := Parent (Ins_Nod);
+ end loop;
+
+ Insert_Before (First (List_Containing (Ins_Nod)), Master_Decl);
Analyze (Master_Decl);
-- Mark the containing scope as a task master. Masters associated