Skip to content

Commit

Permalink
Merge branch 'topic/fix_kp_19312' into 'master'
Browse files Browse the repository at this point in the history
Fix the KP-19312 detector

Closes #412

See merge request eng/libadalang/langkit-query-language!352
  • Loading branch information
HugoGGuerrier committed Jan 6, 2025
2 parents 4865ec4 + aad4a82 commit da059e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lkql_checker/share/lkql/kp/KP-19312.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ fun kp_19312(node) =
|" Flag "for" loop specs which define an iteration filter and which iterate
|" over a type which defines the "iterable" aspect.
node is ForLoopSpec
when node.f_iter_expr.p_expression_type()?.p_has_aspect?("iterable")
and node.f_iter_filter is not null
when node.f_iter_filter is not null
and node.f_iter_expr is e@Expr when (e.p_expression_type()?.p_has_aspect?("iterable"))
4 changes: 4 additions & 0 deletions testsuite/tests/checks/KP-19312/main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ begin
Put_Line ("Elem: " & Elem'Image);
end loop;

for Elem in Integer range 1 .. 10 loop -- NOFLAG
Put_Line ("Elem: " & Elem'Image);
end loop;

for Elem of I loop -- NOFLAG
Put_Line ("Elem: " & Elem'Image);
end loop;
Expand Down
8 changes: 4 additions & 4 deletions testsuite/tests/checks/KP-19312/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ main.adb:35:44: rule violation: possible occurrence of KP 19312
35 | S_1 : constant Integer_Sets.Set := [for E of I when False => E]; -- FLAG
| ^^^^^^^^^^^^^^^^^

main.adb:47:8: rule violation: possible occurrence of KP 19312
47 | for Elem in I when False loop -- FLAG
main.adb:51:8: rule violation: possible occurrence of KP 19312
51 | for Elem in I when False loop -- FLAG
| ^^^^^^^^^^^^^^^^^^^^

main.adb:51:8: rule violation: possible occurrence of KP 19312
51 | for Elem of I when False loop -- FLAG
main.adb:55:8: rule violation: possible occurrence of KP 19312
55 | for Elem of I when False loop -- FLAG
| ^^^^^^^^^^^^^^^^^^^^

0 comments on commit da059e9

Please sign in to comment.