This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Navigation an user-defined operators


The definition of a User-defined operator carries quotes around the name, as
do operators invoked in functional notation. The parser handles these as strings
and their source position is that of the opening quote. This is awkward for
GPS navigation, where we want the highlight of occurrences of the entity to
mark the operator and not the starting quote. This patch modifies the sloc in
the reference table accordingly.

The following command:

   gcc -c bla.adb
   grep "+" bla.ali

must yield:

   2V14 "+"{integer} 2>18 2>24 6b14 9l9 9t12 11s21 13s24

---
procedure Bla is
   function "+" (Left, Right : Integer) return Integer;

   Zero : constant Integer := 0;

   function "+" (Left, Right : Integer) return Integer is
   begin
      return 42;
   end "+";

   A : Integer := 0 + 0;

   B : Integer := Bla."+" (Zero, 10);
   function ">=" (X, Y : Integer) return Boolean is begin
      return X > 0;
   end ">=";

   Yes : Boolean := A >= B;
begin
   null;
end Bla;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-04-02  Ed Schonberg  <schonberg@adacore.com>

	* lib-xref.adb (Generate_Reference): For a reference to an
	operator symbol, set the sloc to point to the first character
	of the operator name, and not to the initial quaote.
	(Output_References): Ditto for the definition of an operator
	symbol.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]