Skip to content

Commit

Permalink
Handle use clauses in a separate package's spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roldak committed May 31, 2024
1 parent 23816e9 commit 0a23a13
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -23499,7 +23499,7 @@ class PackageBody(Body):
# want to reference the envs that are "used" there.
reference(Self.cast(AdaNode).singleton,
through=T.PackageBody.package_decl_uses_clauses_envs,
cond=Not(Self.is_compilation_unit_root))
cond=Not(Self.is_compilation_unit_root) | Self.is_subunit)
)

package_name = Field(type=T.DefiningName)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
separate(Pkg)
package body Inner is
procedure Bar is
X : T;
pragma Test_Statement;
begin
null;
end Bar;
end Inner;
17 changes: 17 additions & 0 deletions testsuite/tests/name_resolution/use_clause_separate_pkg/pkg.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package body Pkg is
package Types is
type T is null record;
end Types;

package Inner is
use Types;
procedure Bar;
end Inner;

procedure Test is
begin
Inner.Bar;
end Test;

package body Inner is separate;
end Pkg;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Pkg is
procedure Test;
end Pkg;
13 changes: 13 additions & 0 deletions testsuite/tests/name_resolution/use_clause_separate_pkg/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Analyzing pkg-inner.adb
#######################

Resolving xrefs for node <ObjectDecl ["X"] pkg-inner.adb:4:7-4:13>
******************************************************************

Expr: <Id "T" pkg-inner.adb:4:11-4:12>
references: <DefiningName "T" pkg.adb:3:12-3:13>
type: None
expected type: None


Done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: name-resolution
input_sources: [pkg-inner.adb]

0 comments on commit 0a23a13

Please sign in to comment.