]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Adjust source location for degenerate scope master
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 15 Dec 2023 12:08:38 +0000 (13:08 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 6 May 2024 09:11:25 +0000 (11:11 +0200)
When the finalization scope master degenerates into a simple master node,
the latter must inherit the source location that the former would have had.

gcc/ada/

* exp_ch7.adb (Build_Finalizer.Process_Object_Declaration): Adjust
the Sloc of the master node declaration in the degenerate case.

gcc/ada/exp_ch7.adb

index 75c9e223956ea7cbfe475f76c11ae00bcfb5b990..4382de9b6b2bc184dfd7236bde714282a254cbbb 100644 (file)
@@ -2875,6 +2875,7 @@ package body Exp_Ch7 is
          Master_Node_Decl   : Node_Id;
          Master_Node_Id     : Entity_Id;
          Master_Node_Ins    : Node_Id;
+         Master_Node_Loc    : Source_Ptr;
          Obj_Ref            : Node_Id;
 
       --  Start of processing for Process_Object_Declaration
@@ -2936,11 +2937,20 @@ package body Exp_Ch7 is
             end if;
 
          else
+            --  For one object, use the Sloc the scope master would have had
+
+            if Counter_Val = 1 then
+               Master_Node_Loc := Sloc (N);
+            else
+               Master_Node_Loc := Loc;
+            end if;
+
             Master_Node_Id :=
-              Make_Defining_Identifier (Loc,
+              Make_Defining_Identifier (Master_Node_Loc,
                 Chars => New_External_Name (Chars (Obj_Id), Suffix => "MN"));
             Master_Node_Decl :=
-              Make_Master_Node_Declaration (Loc, Master_Node_Id, Obj_Id);
+              Make_Master_Node_Declaration (Master_Node_Loc,
+                Master_Node_Id, Obj_Id);
 
             Push_Scope (Scope (Obj_Id));
             if Counter_Val = 1 then