Skip to content

Commit

Permalink
Merge branch 'topic/1334' into 'master'
Browse files Browse the repository at this point in the history
Add a new CallExpr kind for family indexes

Closes #1334

See merge request eng/libadalang/libadalang!1605
  • Loading branch information
thvnx committed Apr 2, 2024
2 parents 7bd17f0 + 3ecbd08 commit d371733
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -16276,11 +16276,13 @@ class CallExprKind(Enum):
- ``array_slice``, ``array_index`` is when the CallExpr is in fact an
array slice or an array subcomponent access expression, respectively.
- ``type_conversion`` is when the CallExpr is a type conversion.
- ``family_index`` is for entry calls using a family index.
"""
call = EnumValue()
array_slice = EnumValue()
array_index = EnumValue()
type_conversion = EnumValue()
family_index = EnumValue()


class CallExpr(Name):
Expand Down Expand Up @@ -16331,6 +16333,12 @@ def kind():
),
CallExprKind.type_conversion,

# This is important to make this test *after* the check for
# ``is_call`` so that real entry calls are correctly flagged as
# such. We only want to catch family indexes here.
Entity.name.referenced_decl.is_a(T.EntryDecl),
CallExprKind.family_index,

# Should not happen
PropertyError(CallExprKind, "undetermined CallExpr kind")
)
Expand Down
26 changes: 26 additions & 0 deletions testsuite/tests/properties/call_expr_kind/family_index.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
procedure Family_Index is
subtype Index_T is Positive range 1 .. 2;

protected T is
entry E (I : Integer);
entry F (Index_T) (I : Integer);
end T;

protected body T is
entry E (I : Integer) when True is
begin
requeue F (I);
--% node.f_call_name.p_kind
end E;

entry F (for I in Index_T) (I : Integer) when False is
begin
null;
end F;
end T;

begin
T.F (1) (3);
--% node.f_call.p_kind
--% node.f_call.f_name.p_kind
end Family_Index;
15 changes: 15 additions & 0 deletions testsuite/tests/properties/call_expr_kind/test.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
Working on node <RequeueStmt family_index.adb:12:10-12:24>
==========================================================

Eval 'node.f_call_name.p_kind'
Result: 'family_index'

Working on node <CallStmt family_index.adb:23:4-23:16>
======================================================

Eval 'node.f_call.p_kind'
Result: 'call'

Eval 'node.f_call.f_name.p_kind'
Result: 'family_index'

Working on node <CallStmt kind.adb:26:7-26:14>
==============================================

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/properties/call_expr_kind/test.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
driver: inline-playground
input_sources: [kind.adb]
input_sources: [kind.adb, family_index.adb]

0 comments on commit d371733

Please sign in to comment.