Skip to content

Commit da059e9

Browse files
committed
Merge branch 'topic/fix_kp_19312' into 'master'
Fix the KP-19312 detector Closes #412 See merge request eng/libadalang/langkit-query-language!352
2 parents 4865ec4 + aad4a82 commit da059e9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lkql_checker/share/lkql/kp/KP-19312.lkql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ fun kp_19312(node) =
55
|" Flag "for" loop specs which define an iteration filter and which iterate
66
|" over a type which defines the "iterable" aspect.
77
node is ForLoopSpec
8-
when node.f_iter_expr.p_expression_type()?.p_has_aspect?("iterable")
9-
and node.f_iter_filter is not null
8+
when node.f_iter_filter is not null
9+
and node.f_iter_expr is e@Expr when (e.p_expression_type()?.p_has_aspect?("iterable"))

testsuite/tests/checks/KP-19312/main.adb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ begin
4040
Put_Line ("Elem: " & Elem'Image);
4141
end loop;
4242

43+
for Elem in Integer range 1 .. 10 loop -- NOFLAG
44+
Put_Line ("Elem: " & Elem'Image);
45+
end loop;
46+
4347
for Elem of I loop -- NOFLAG
4448
Put_Line ("Elem: " & Elem'Image);
4549
end loop;

testsuite/tests/checks/KP-19312/test.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ main.adb:35:44: rule violation: possible occurrence of KP 19312
22
35 | S_1 : constant Integer_Sets.Set := [for E of I when False => E]; -- FLAG
33
| ^^^^^^^^^^^^^^^^^
44

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

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

0 commit comments

Comments
 (0)