Skip to content

Commit 488668d

Browse files
committed
Merge branch 'topic/kp_19753' into 'master'
Add detector for KP-19753 Closes #440 See merge request eng/libadalang/langkit-query-language!405
2 parents 1a0e45d + 01a3061 commit 488668d

File tree

7 files changed

+94
-0
lines changed

7 files changed

+94
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@check(help="possible occurrence of KP 19753",
2+
message="possible occurrence of KP 19753")
3+
fun kp_19753(node) =
4+
|" Flag loop body which have a raise statement as first non-null statement.
5+
node is BaseLoopStmt
6+
when [n for n in node.f_stmts.children if n is not NullStmt]?[1] is RaiseStmt

lkql_checker/share/lkql/kp/kp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"kp_19529": "24.*",
2323
"kp_19625": "24.*",
2424
"kp_19696": "24.*,25.1",
25+
"kp_19753": "21.*,22.*,23.*,24.*,25.*",
2526
"kp_ob03_009": "19.*",
2627
"kp_p226_024": "7.1.*,7.2.*,7.3.*,7.4.1,7.4.2,7.4.3",
2728
"kp_q309_014": "7.1.*,7.2.*,7.3.*,7.4.*,17.*",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
procedure Main is
2+
A : array (1 .. 5) of Integer;
3+
begin
4+
for I in 1 .. 5 loop -- FLAG
5+
raise Constraint_Error;
6+
end loop;
7+
8+
for I of A loop -- FLAG
9+
raise Constraint_Error;
10+
end loop;
11+
12+
loop -- FLAG
13+
raise Constraint_Error;
14+
end loop;
15+
16+
loop -- FLAG
17+
null;
18+
null;
19+
null;
20+
raise Constraint_Error;
21+
end loop;
22+
23+
loop -- FLAG
24+
null;
25+
null;
26+
null;
27+
raise Constraint_Error;
28+
A (1) := 0;
29+
end loop;
30+
31+
loop -- NOFLAG
32+
A (1) := 0;
33+
raise Constraint_Error;
34+
end loop;
35+
end Main;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project Prj is
2+
end Prj;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
main.adb:4:4: rule violation: possible occurrence of KP 19753
2+
4 | for I in 1 .. 5 loop -- FLAG
3+
| ____^
4+
||
5+
|| ~~~ 1 other lines ~~~
6+
||
7+
6 || end loop;
8+
||____________^
9+
10+
main.adb:8:4: rule violation: possible occurrence of KP 19753
11+
8 | for I of A loop -- FLAG
12+
| ____^
13+
||
14+
|| ~~~ 1 other lines ~~~
15+
||
16+
10 || end loop;
17+
||____________^
18+
19+
main.adb:12:4: rule violation: possible occurrence of KP 19753
20+
12 | loop -- FLAG
21+
| ____^
22+
||
23+
|| ~~~ 1 other lines ~~~
24+
||
25+
14 || end loop;
26+
||____________^
27+
28+
main.adb:16:4: rule violation: possible occurrence of KP 19753
29+
16 | loop -- FLAG
30+
| ____^
31+
||
32+
|| ~~~ 4 other lines ~~~
33+
||
34+
21 || end loop;
35+
||____________^
36+
37+
main.adb:23:4: rule violation: possible occurrence of KP 19753
38+
23 | loop -- FLAG
39+
| ____^
40+
||
41+
|| ~~~ 5 other lines ~~~
42+
||
43+
29 || end loop;
44+
||____________^
45+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
driver: checker
2+
rule_name: kp_19753
3+
project: prj.gpr

testsuite/tests/gnatcheck/xml_help/test.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ testsuite_driver: No output file generated by gnatcheck
8888
<check switch="+Rkp_19529" label="possible occurrence of KP 19529"/>
8989
<check switch="+Rkp_19625" label="possible occurrence of KP 19625"/>
9090
<check switch="+Rkp_19696" label="possible occurrence of KP 19696"/>
91+
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
9192
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
9293
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
9394
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>
@@ -598,6 +599,7 @@ testsuite_driver: No output file generated by gnatcheck
598599
<check switch="+Rkp_19529" label="possible occurrence of KP 19529"/>
599600
<check switch="+Rkp_19625" label="possible occurrence of KP 19625"/>
600601
<check switch="+Rkp_19696" label="possible occurrence of KP 19696"/>
602+
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
601603
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
602604
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
603605
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>

0 commit comments

Comments
 (0)