Skip to content

Commit

Permalink
Merge branch 'topic/1248' into 'master'
Browse files Browse the repository at this point in the history
gnat_xref: handle references to generic formal objects

Closes #1248

See merge request eng/libadalang/libadalang!1524
  • Loading branch information
thvnx committed Feb 14, 2024
2 parents 154deff + 99807e9 commit 059f34c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,11 @@ def gnat_xref():
),
bd.semantic_parent.cast(T.BasicDecl).defining_name,

bd._.parent._.is_a(T.GenericFormal),
bd.parents.find(
lambda p: p.is_a(T.GenericDecl)
).cast(T.GenericDecl).decl.defining_name,

bd.then(lambda bd: bd.is_a(T.DiscriminantSpec)),
bd.semantic_parent.cast(T.BasicDecl).defining_name,

Expand Down
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
procedure Test is
generic
type T is (<>);
A, B, C : Integer;
with function F return Integer;
with procedure G;
package P is end P;

generic
type T is (<>);
A, B, C : Integer;
with function F return Integer;
with procedure G;
procedure Proc;
-- GNAT doesn't add references to generic subprogram formal objects as it
-- does for generic packages. If GNAT supports them one day, gnat_compare
-- already supports it.

procedure Proc is
begin
null;
end Proc;
begin
null;
end;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
== test.adb ==
test.adb:1:11 => test.adb:1:11 (LAL: ok)
test.adb:3:12 => test.adb:7:12 (LAL: ok)
test.adb:4:7 => test.adb:7:12 (LAL: ok)
test.adb:4:10 => test.adb:7:12 (LAL: ok)
test.adb:4:13 => test.adb:7:12 (LAL: ok)
test.adb:5:21 => test.adb:7:12 (LAL: ok)
test.adb:6:22 => test.adb:7:12 (LAL: ok)
test.adb:7:21 => test.adb:7:12 (LAL: ok)
test.adb:19:14 => test.adb:14:14 (LAL: ok)
test.adb:22:8 => test.adb:14:14 (LAL: ok)

Stats:
GNAT xrefs have 10 entries
LAL xrefs have:
* 10 OK entries (100.00%)
* 0 DIFFERENT entries (0.00%)
* 0 ERROR entries (0.00%)
* 0 MISSING entries (0.00%)
* 0 ADDITIONAL entries (0.00%)
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 059f34c

Please sign in to comment.