Skip to content

Commit

Permalink
Merge branch 'topic/positional_params' into 'master'
Browse files Browse the repository at this point in the history
Enhance the 'Positonal_Parameters' rule

Closes #249

See merge request eng/libadalang/langkit-query-language!199
  • Loading branch information
HugoGGuerrier committed Apr 17, 2024
2 parents 9a0d29c + 47b0c0a commit b43fc4d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lkql_checker/share/lkql/positional_parameters.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ fun check_actual_param(spec, node, check_dot) =
fun positional_parameters(node, all=false) =
node is ParamAssoc(f_designator is null, parent is l@AssocList)
when l.parent is c@CallExpr(
p_is_call() is true,
f_name is not AttributeRef,
f_name is id@*(p_is_operator_name() is false)
when (all or check_actual_param(id.p_called_subp_spec(), node,
when (all or check_actual_param(c.p_called_subp_spec(), node,
id.p_is_dot_call())))
2 changes: 2 additions & 0 deletions testsuite/tests/checks/positional_parameters/pack.ads
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ package Pack is

task T is
entry E1 (I : Integer; J : Integer);
entry E2 (Boolean) (I : Integer; J : Integer);
entry E3 (Boolean);
end T;

end Pack;
2 changes: 2 additions & 0 deletions testsuite/tests/checks/positional_parameters/pos.adb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ begin

-- Entry call
T.E1 (10, 11); -- FLAG (2)
T.E2 (True) (10, 11); -- FLAG (2)
T.E3 (True); -- NOFLAG

-- Function calls
I := Fun1 (J); -- NOFLAG because ALL is not set
Expand Down
28 changes: 18 additions & 10 deletions testsuite/tests/checks/positional_parameters/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,31 @@ pos.adb:33:14: rule violation: positional parameter association
33 | T.E1 (10, 11); -- FLAG (2)
| ^^

pos.adb:37:15: rule violation: positional parameter association
37 | I := Fun2 (J, K); -- FLAG (2)
pos.adb:34:17: rule violation: positional parameter association
34 | T.E2 (True) (10, 11); -- FLAG (2)
| ^^

pos.adb:34:21: rule violation: positional parameter association
34 | T.E2 (True) (10, 11); -- FLAG (2)
| ^^

pos.adb:39:15: rule violation: positional parameter association
39 | I := Fun2 (J, K); -- FLAG (2)
| ^

pos.adb:37:18: rule violation: positional parameter association
37 | I := Fun2 (J, K); -- FLAG (2)
pos.adb:39:18: rule violation: positional parameter association
39 | I := Fun2 (J, K); -- FLAG (2)
| ^

pos.adb:38:23: rule violation: positional parameter association
38 | I := Fun2_Default (J); -- FLAG
pos.adb:40:23: rule violation: positional parameter association
40 | I := Fun2_Default (J); -- FLAG
| ^

pos.adb:43:11: rule violation: positional parameter association
43 | Proc2 (I); -- FLAG
pos.adb:45:11: rule violation: positional parameter association
45 | Proc2 (I); -- FLAG
| ^

pos.adb:52:19: rule violation: positional parameter association
52 | Var_T.T_Proc3 (10); -- FLAG
pos.adb:54:19: rule violation: positional parameter association
54 | Var_T.T_Proc3 (10); -- FLAG
| ^^

0 comments on commit b43fc4d

Please sign in to comment.