Skip to content

Commit

Permalink
gnat_compare: skip 'E' xrefs (reference to first private entity)
Browse files Browse the repository at this point in the history
When comparing GNAT's xrefs with libadalang nameres, skip references
to the first private entity.
  • Loading branch information
thvnx committed Feb 8, 2024
1 parent 80b544a commit 1a36647
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
9 changes: 7 additions & 2 deletions testsuite/ada/gnat_compare/xrefs.adb
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,15 @@ package body Xrefs is
raise Program_Error;
end if;

-- Ignore "end of spec/body" xrefs, which point on the ending
-- Ignore "end of spec/body" xrefs (e/t), which point on the ending
-- semicolon of an entity body. LAL won't support that.
--
-- Ignore "first private entity" (E) xref, which points on the first
-- private entity of a given package.

if Current_Xrefs /= null and then Type_Char not in 'e' | 't' then
if Current_Xrefs /= null
and then Type_Char not in 'e' | 't' | 'E'
then
Current_Xrefs.Xrefs.Append
(Xref_Type'(Ref_Sloc => (Line_Number (Line),
Column_Number (Column)),
Expand Down
4 changes: 4 additions & 0 deletions testsuite/tests/name_resolution/gnat_compare_2/prj.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project Prj is
for Source_Dirs use (".");
for Main use ("test.adb");
end Prj;
8 changes: 8 additions & 0 deletions testsuite/tests/name_resolution/gnat_compare_2/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
procedure Test is
package P is
private
type I is new Integer;
end P;
begin
null;
end Test;
13 changes: 13 additions & 0 deletions testsuite/tests/name_resolution/gnat_compare_2/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
== test.adb ==
test.adb:1:11 => test.adb:1:11 (LAL: ok)
test.adb:5:8 => test.adb:2:12 (LAL: ok)
test.adb:8:5 => test.adb:1:11 (LAL: ok)

Stats:
GNAT xrefs have 3 entries
LAL xrefs have:
* 3 OK entries (100.00%)
* 0 DIFFERENT entries (0.00%)
* 0 ERROR entries (0.00%)
* 0 MISSING entries (0.00%)
* 0 ADDITIONAL entries (0.00%)
2 changes: 2 additions & 0 deletions testsuite/tests/name_resolution/gnat_compare_2/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: gnat-compare
project_file: prj.gpr

0 comments on commit 1a36647

Please sign in to comment.