From 3ecbd08178c16313bd44d9841ce2210abf2d0b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Th=C3=A9venoux?= Date: Tue, 2 Apr 2024 15:01:12 +0200 Subject: [PATCH] Add a new CallExpr kind for family indexes --- ada/ast.py | 8 ++++++ .../call_expr_kind/family_index.adb | 26 +++++++++++++++++++ .../tests/properties/call_expr_kind/test.out | 15 +++++++++++ .../tests/properties/call_expr_kind/test.yaml | 2 +- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 testsuite/tests/properties/call_expr_kind/family_index.adb diff --git a/ada/ast.py b/ada/ast.py index dedf3db0c..969c98c49 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -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): @@ -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") ) diff --git a/testsuite/tests/properties/call_expr_kind/family_index.adb b/testsuite/tests/properties/call_expr_kind/family_index.adb new file mode 100644 index 000000000..c6824b23f --- /dev/null +++ b/testsuite/tests/properties/call_expr_kind/family_index.adb @@ -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; diff --git a/testsuite/tests/properties/call_expr_kind/test.out b/testsuite/tests/properties/call_expr_kind/test.out index 1e2979855..093a356f9 100644 --- a/testsuite/tests/properties/call_expr_kind/test.out +++ b/testsuite/tests/properties/call_expr_kind/test.out @@ -1,3 +1,18 @@ +Working on node +========================================================== + +Eval 'node.f_call_name.p_kind' +Result: 'family_index' + +Working on node +====================================================== + +Eval 'node.f_call.p_kind' +Result: 'call' + +Eval 'node.f_call.f_name.p_kind' +Result: 'family_index' + Working on node ============================================== diff --git a/testsuite/tests/properties/call_expr_kind/test.yaml b/testsuite/tests/properties/call_expr_kind/test.yaml index 9733066be..72a5673b5 100644 --- a/testsuite/tests/properties/call_expr_kind/test.yaml +++ b/testsuite/tests/properties/call_expr_kind/test.yaml @@ -1,2 +1,2 @@ driver: inline-playground -input_sources: [kind.adb] +input_sources: [kind.adb, family_index.adb]