]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Keep source locations for inlined subprograms from predefined units
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 17 Oct 2025 08:33:44 +0000 (10:33 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 3 Nov 2025 14:15:17 +0000 (15:15 +0100)
Frontend inlining, which is now deprecated and only enabled with switch -gnatN
is used, used to reset source locations for subprograms from predefined units.
This was a workaround to prevent the debugger from visiting internal code in
Ada.Tags, but this problem no longer occurs (even when switch -gnatN is used)
and is no longer needed. This patch removes it, because it confused
compile-time evaluation, which makes use of source locations to recognize code
within IF statements.

gcc/ada/ChangeLog:

* inline.adb (Process_Sloc): Remove.

gcc/ada/inline.adb

index 9e60fa81de9e51c0993aa9c03fc134d419ecb845..a966c28351f30e1ae1d9d65c9bf10868457bcdee 100644 (file)
@@ -3380,15 +3380,6 @@ package body Inline is
       --  be performed in a separate pass, using an instantiation of the
       --  previous subprogram over aspect specifications reachable from N.
 
-      function Process_Sloc (Nod : Node_Id) return Traverse_Result;
-      --  If the call being expanded is that of an internal subprogram, set the
-      --  sloc of the generated block to that of the call itself, so that the
-      --  expansion is skipped by the "next" command in gdb. Same processing
-      --  for a subprogram in a predefined file, e.g. Ada.Tags. If
-      --  Debug_Generated_Code is true, suppress this change to simplify our
-      --  own development. Same in GNATprove mode, to ensure that warnings and
-      --  diagnostics point to the proper location.
-
       procedure Reset_Dispatching_Calls (N : Node_Id);
       --  In subtree N search for occurrences of dispatching calls that use the
       --  Ada 2005 Object.Operation notation and the object is a formal of the
@@ -3647,22 +3638,6 @@ package body Inline is
       procedure Replace_Formals_In_Aspects is
         new Traverse_Proc (Process_Formals_In_Aspects);
 
-      ------------------
-      -- Process_Sloc --
-      ------------------
-
-      function Process_Sloc (Nod : Node_Id) return Traverse_Result is
-      begin
-         if not Debug_Generated_Code then
-            Set_Sloc (Nod, Sloc (N));
-            Set_Comes_From_Source (Nod, False);
-         end if;
-
-         return OK;
-      end Process_Sloc;
-
-      procedure Reset_Slocs is new Traverse_Proc (Process_Sloc);
-
       ------------------------------
       --  Reset_Dispatching_Calls --
       ------------------------------
@@ -4176,13 +4151,6 @@ package body Inline is
       Replace_Formals_In_Aspects (Blk);
       Set_Parent (Blk, N);
 
-      if GNATprove_Mode then
-         null;
-
-      elsif not Comes_From_Source (Subp) or else Is_Predef then
-         Reset_Slocs (Blk);
-      end if;
-
       if Is_Unc_Decl then
 
          --  No action needed since return statement has been already removed