]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Correct xref of operator expression function body
authorBob Duff <duff@adacore.com>
Thu, 12 Dec 2024 14:13:16 +0000 (09:13 -0500)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 6 Jan 2025 09:14:48 +0000 (10:14 +0100)
For an expression function body that is an operator,
make sure the xref entry in the ALI file points one past the
double quote mark. For example, if the name is ">", point
to the greater-than symbol, not the double quote.
This was already the case for proper bodies.

gcc/ada/ChangeLog:

* sem_util.adb (Copy_Subprogram_Spec): When copying
an N_Defining_Operator_Symbol, create an
N_Defining_Operator_Symbol rather than an N_Defining_Identifier.
This will cause Lib.Xref to "skip the initial quote for
navigation purposes" (as per comments in Lib.Xref body).

gcc/ada/sem_util.adb

index ffc631a7beeb426814661a3772ff83006afbea6c..2b5b51b40ad375be9e10d91cfa7ab64737cbb26c 100644 (file)
@@ -6228,8 +6228,17 @@ package body Sem_Util is
       --  Create a new entity for the defining unit name
 
       Def_Id := Defining_Unit_Name (Result);
-      Set_Defining_Unit_Name (Result,
-        Make_Defining_Identifier (Sloc (Def_Id), Chars (Def_Id)));
+
+      case Nkind (Def_Id) is
+         when N_Defining_Identifier =>
+            Def_Id := Make_Defining_Identifier (Sloc (Def_Id), Chars (Def_Id));
+         when N_Defining_Operator_Symbol =>
+            Def_Id :=
+              Make_Defining_Operator_Symbol (Sloc (Def_Id), Chars (Def_Id));
+         when others => raise Program_Error;
+      end case;
+
+      Set_Defining_Unit_Name (Result, Def_Id);
 
       --  Create new entities for the formal parameters