Skip to content

Commit

Permalink
Fix accept statement xref_equation
Browse files Browse the repository at this point in the history
This commit ensures that the entry index expression of an accept
statement is binded to the type defined by the corresponding entry
declaration.

As per ARM 9.5.2: the expected type for an entry index is that of the
subtype defined by the discrete subtype definition of the
corresponding entry declaration.
  • Loading branch information
thvnx committed Dec 6, 2023
1 parent c42c3e4 commit 6dd4655
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -22398,7 +22398,13 @@ def xref_equation():
return And(
Bind(Self.body_decl.name.ref_var, Entity.designated_entry),
Entity.entry_index_expr.then(
lambda e: e.sub_equation,
lambda e:
# :rmlink:`9.5.2`: The expected type for entry_index_expr is
# that of the type defined by the definition of the
# corresponding entry declaration.
Bind(e.expected_type_var,
Entity.designated_entry.family_type)
& e.sub_equation,
default_val=LogicTrue()
)
)
Expand Down
15 changes: 15 additions & 0 deletions testsuite/tests/name_resolution/accept_stmt/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
procedure Test is
task t is
entry ent1 (character);
end t;

task body t is
begin
accept ent1 ('c') do
null;
end;
pragma Test_Statement;
end t;
begin
null;
end Test;
13 changes: 13 additions & 0 deletions testsuite/tests/name_resolution/accept_stmt/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Analyzing test.adb
##################

Resolving xrefs for node <AcceptStmtWithStmts test.adb:8:7-10:11>
*****************************************************************

Expr: <Chr "'c'" test.adb:8:20-8:23>
references: <SyntheticDefiningName "'c'" __standard:21:3-21:27>
type: <ConcreteTypeDecl ["Character"] __standard:21:3-21:27>
expected type: <ConcreteTypeDecl ["Character"] __standard:21:3-21:27>


Done.
2 changes: 2 additions & 0 deletions testsuite/tests/name_resolution/accept_stmt/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 6dd4655

Please sign in to comment.