diff --git a/ada/ast.py b/ada/ast.py index ee6db89da..ead5cbe72 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -4510,11 +4510,15 @@ def get_param(part=T.BasicDecl.entity, param=T.Symbol): dynamic_vars=[default_imprecise_fallback()]) def decl_param(param=T.DefiningName.entity): """ - If self is a ParamSpec of a subprogram body, go fetch the equivalent - spec in the subprogram decl. + If self is a ParamSpec of a subprogram body or of an accept stmt, go + fetch the equivalent spec in the subprogram decl. """ return Entity.get_param( - Entity.parent_decl.cast(T.BaseSubpBody)._.decl_part, + Entity.semantic_parent.match( + lambda body=T.BaseSubpBody: body.decl_part, + lambda accept=T.AcceptStmt: accept.corresponding_entry, + lambda _: No(T.BasicDecl.entity) + ), param.name_symbol )._or(param) diff --git a/testsuite/tests/name_resolution/gnat_compare_entry_param/prj.gpr b/testsuite/tests/name_resolution/gnat_compare_entry_param/prj.gpr new file mode 100644 index 000000000..4b29ca3fd --- /dev/null +++ b/testsuite/tests/name_resolution/gnat_compare_entry_param/prj.gpr @@ -0,0 +1,4 @@ +project Prj is + for Source_Dirs use ("."); + for Main use ("test.adb"); +end Prj; diff --git a/testsuite/tests/name_resolution/gnat_compare_entry_param/test.adb b/testsuite/tests/name_resolution/gnat_compare_entry_param/test.adb new file mode 100644 index 000000000..76a3e3fab --- /dev/null +++ b/testsuite/tests/name_resolution/gnat_compare_entry_param/test.adb @@ -0,0 +1,17 @@ +procedure Test is + task T is + entry E (C1 : Integer; C2 : Boolean); + end T; + + task body T is + X : Integer; + begin + accept E (C1 : Integer; C2 : Boolean) do + if C2 then + X := C1; + end if; + end E; + end T; +begin + null; +end Test; diff --git a/testsuite/tests/name_resolution/gnat_compare_entry_param/test.out b/testsuite/tests/name_resolution/gnat_compare_entry_param/test.out new file mode 100644 index 000000000..285eabaf6 --- /dev/null +++ b/testsuite/tests/name_resolution/gnat_compare_entry_param/test.out @@ -0,0 +1,21 @@ +== test.adb == +test.adb:1:11 => test.adb:1:11 (LAL: ok) +test.adb:3:16 => test.adb:3:13 (LAL: ok) +test.adb:3:30 => test.adb:3:13 (LAL: ok) +test.adb:6:14 => test.adb:2:9 (LAL: ok) +test.adb:9:14 => test.adb:3:13 (LAL: ok) +test.adb:10:13 => test.adb:3:30 (LAL: ok) +test.adb:11:13 => test.adb:7:7 (LAL: ok) +test.adb:11:18 => test.adb:3:16 (LAL: ok) +test.adb:13:11 => test.adb:3:13 (LAL: ok) +test.adb:14:8 => test.adb:2:9 (LAL: ok) +test.adb:17:5 => test.adb:1:11 (LAL: ok) + +Stats: +GNAT xrefs have 11 entries +LAL xrefs have: + * 11 OK entries (100.00%) + * 0 DIFFERENT entries (0.00%) + * 0 ERROR entries (0.00%) + * 0 MISSING entries (0.00%) + * 0 ADDITIONAL entries (0.00%) diff --git a/testsuite/tests/name_resolution/gnat_compare_entry_param/test.yaml b/testsuite/tests/name_resolution/gnat_compare_entry_param/test.yaml new file mode 100644 index 000000000..9efa742f3 --- /dev/null +++ b/testsuite/tests/name_resolution/gnat_compare_entry_param/test.yaml @@ -0,0 +1,2 @@ +driver: gnat-compare +project_file: prj.gpr