Skip to content

Commit

Permalink
Support RequeueStmt resolution when call name refers to a CallExpr wi…
Browse files Browse the repository at this point in the history
…th args

This change adds support for name resolution of a RequeueStmt when the
called name refers to a CallExpr with arguments as for example when
the CallExpr is an array index.
  • Loading branch information
thvnx committed Dec 5, 2023
1 parent fd9a7d9 commit 1b18181
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -21963,7 +21963,19 @@ def xref_equation():
return And(
# We call xref_no_overloading to make sure that sub-names are
# bound.
name.xref_no_overloading,
name.match(
# If name is a DottedName, prefix can be a CallExpr that should
# be resolved using sub_equation.
lambda dn=T.DottedName:
If(dn.prefix.is_a(CallExpr),
dn.prefix.sub_equation,
dn.prefix.xref_no_overloading)
& env.bind(
dn.prefix.designated_env,
dn.suffix.xref_no_overloading
),
lambda o: o.xref_no_overloading
),

# Then, bind the name to any entry that fits the bills
entries.logic_any(lambda e: Let(
Expand Down
39 changes: 39 additions & 0 deletions testsuite/tests/name_resolution/requeue_stmt_3/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
procedure Test is
protected type PT is
entry Process;
end PT;

protected body PT is
entry Process when True is
begin
null;
end Process;
end PT;

type My_Range is range 1 .. 2;
type My_Array is array (My_Range) of PT;
Arr : My_Array;

function F (I, J : Float) return My_Range is
begin
return My_Range (I * J);
end F;

task T is
entry P (Name : String);
end T;

task body T is
Index : My_Range := 1;
begin
accept P (Name : String) do
requeue Arr (Index).Process;
pragma Test_Statement;

requeue Arr (F (4.3, 8.9)).Process;
pragma Test_Statement;
end P;
end T;
begin
null;
end Test;
65 changes: 65 additions & 0 deletions testsuite/tests/name_resolution/requeue_stmt_3/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Analyzing test.adb
##################

Resolving xrefs for node <RequeueStmt test.adb:30:10-30:38>
***********************************************************

Expr: <DottedName test.adb:30:18-30:37>
references: <DefiningName "Process" test.adb:3:13-3:20>
type: None
expected type: None
Expr: <CallExpr test.adb:30:18-30:29>
references: <DefiningName "Arr" test.adb:15:4-15:7>
type: <ProtectedTypeDecl ["PT"] test.adb:2:4-4:11>
expected type: None
Expr: <Id "Arr" test.adb:30:18-30:21>
references: <DefiningName "Arr" test.adb:15:4-15:7>
type: <ConcreteTypeDecl ["My_Array"] test.adb:14:4-14:44>
expected type: None
Expr: <Id "Index" test.adb:30:23-30:28>
references: <DefiningName "Index" test.adb:27:7-27:12>
type: <ConcreteTypeDecl ["My_Range"] test.adb:13:4-13:34>
expected type: <ConcreteTypeDecl ["My_Range"] test.adb:13:4-13:34>
Expr: <Id "Process" test.adb:30:30-30:37>
references: <DefiningName "Process" test.adb:3:13-3:20>
type: None
expected type: None

Resolving xrefs for node <RequeueStmt test.adb:33:10-33:45>
***********************************************************

Expr: <DottedName test.adb:33:18-33:44>
references: <DefiningName "Process" test.adb:3:13-3:20>
type: None
expected type: None
Expr: <CallExpr test.adb:33:18-33:36>
references: <DefiningName "Arr" test.adb:15:4-15:7>
type: <ProtectedTypeDecl ["PT"] test.adb:2:4-4:11>
expected type: None
Expr: <Id "Arr" test.adb:33:18-33:21>
references: <DefiningName "Arr" test.adb:15:4-15:7>
type: <ConcreteTypeDecl ["My_Array"] test.adb:14:4-14:44>
expected type: None
Expr: <CallExpr test.adb:33:23-33:35>
references: <DefiningName "F" test.adb:17:13-17:14>
type: <ConcreteTypeDecl ["My_Range"] test.adb:13:4-13:34>
expected type: <ConcreteTypeDecl ["My_Range"] test.adb:13:4-13:34>
Expr: <Id "F" test.adb:33:23-33:24>
references: <DefiningName "F" test.adb:17:13-17:14>
type: <ConcreteTypeDecl ["My_Range"] test.adb:13:4-13:34>
expected type: None
Expr: <Real test.adb:33:26-33:29>
references: None
type: <ConcreteTypeDecl ["Universal_Real_Type_"] __standard:117:3-117:42>
expected type: <ConcreteTypeDecl ["Float"] __standard:14:3-15:51>
Expr: <Real test.adb:33:31-33:34>
references: None
type: <ConcreteTypeDecl ["Universal_Real_Type_"] __standard:117:3-117:42>
expected type: <ConcreteTypeDecl ["Float"] __standard:14:3-15:51>
Expr: <Id "Process" test.adb:33:37-33:44>
references: <DefiningName "Process" test.adb:3:13-3:20>
type: None
expected type: None


Done.
2 changes: 2 additions & 0 deletions testsuite/tests/name_resolution/requeue_stmt_3/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: name-resolution
input_sources: [test.adb]

0 comments on commit 1b18181

Please sign in to comment.