Skip to content

Commit 3c439a2

Browse files
committed
Merge branch 'topic/kp_19747' into 'master'
Add detector for KP-19747 Closes #438 See merge request eng/libadalang/langkit-query-language!399
2 parents 488668d + 76e355f commit 3c439a2

File tree

7 files changed

+73
-0
lines changed

7 files changed

+73
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@check(help="possible occurrence of KP 19747",
2+
message="possible occurrence of KP 19747")
3+
fun kp_19747(node) =
4+
|" Flag access types whose designated type is an array type whose component
5+
|" type is itself an access type.
6+
node is BaseTypeDecl(
7+
p_root_type: BaseTypeDecl(
8+
p_is_access_type(): true,
9+
p_accessed_type(): at@BaseTypeDecl(
10+
p_is_array_type(): true
11+
) when at.p_root_type()
12+
.f_type_def
13+
.f_component_type
14+
.f_type_expr
15+
.p_designated_type_decl()
16+
.p_is_access_type()
17+
)
18+
)

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_19747": "24.*",
2526
"kp_19753": "21.*,22.*,23.*,24.*,25.*",
2627
"kp_ob03_009": "19.*",
2728
"kp_p226_024": "7.1.*,7.2.*,7.3.*,7.4.1,7.4.2,7.4.3",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
procedure Main is
2+
type Acc_Int is access Integer;
3+
subtype S_Acc_Int is Acc_Int;
4+
type D_Acc_Int is new Acc_Int;
5+
6+
type Arr_Acc_Int is array (1 .. 5) of Acc_Int;
7+
type Arr_S_Acc_Int is array (1 .. 5) of S_Acc_Int;
8+
type Arr_D_Acc_Int is array (1 .. 5) of D_Acc_Int;
9+
subtype S_Arr_Acc_Int is Arr_Acc_Int;
10+
type D_Arr_Acc_Int is new Arr_Acc_Int;
11+
type Arr_Ano_Acc_Int is array (1 .. 5) of access Integer;
12+
type Arr_Int is array (1 .. 5) of Integer;
13+
14+
type Arr_Acc is access Arr_Acc_Int; -- FLAG
15+
type Arr_S_Acc is access Arr_S_Acc_Int; -- FLAG
16+
type Arr_D_Acc is access Arr_D_Acc_Int; -- FLAG
17+
type S_Arr_Acc is access S_Arr_Acc_Int; -- FLAG
18+
type D_Arr_Acc is access D_Arr_Acc_Int; -- FLAG
19+
type Ano_Arr_Acc is access Arr_Ano_Acc_Int; -- FLAG
20+
type Arr is access Arr_Int; -- NOFLAG
21+
begin
22+
null;
23+
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
main.adb:14:9: rule violation: possible occurrence of KP 19747
2+
14 | type Arr_Acc is access Arr_Acc_Int; -- FLAG
3+
| ^^^^^^^
4+
5+
main.adb:15:9: rule violation: possible occurrence of KP 19747
6+
15 | type Arr_S_Acc is access Arr_S_Acc_Int; -- FLAG
7+
| ^^^^^^^^^
8+
9+
main.adb:16:9: rule violation: possible occurrence of KP 19747
10+
16 | type Arr_D_Acc is access Arr_D_Acc_Int; -- FLAG
11+
| ^^^^^^^^^
12+
13+
main.adb:17:9: rule violation: possible occurrence of KP 19747
14+
17 | type S_Arr_Acc is access S_Arr_Acc_Int; -- FLAG
15+
| ^^^^^^^^^
16+
17+
main.adb:18:9: rule violation: possible occurrence of KP 19747
18+
18 | type D_Arr_Acc is access D_Arr_Acc_Int; -- FLAG
19+
| ^^^^^^^^^
20+
21+
main.adb:19:9: rule violation: possible occurrence of KP 19747
22+
19 | type Ano_Arr_Acc is access Arr_Ano_Acc_Int; -- FLAG
23+
| ^^^^^^^^^^^
24+
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_19747
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_19747" label="possible occurrence of KP 19747"/>
9192
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
9293
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
9394
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
@@ -599,6 +600,7 @@ testsuite_driver: No output file generated by gnatcheck
599600
<check switch="+Rkp_19529" label="possible occurrence of KP 19529"/>
600601
<check switch="+Rkp_19625" label="possible occurrence of KP 19625"/>
601602
<check switch="+Rkp_19696" label="possible occurrence of KP 19696"/>
603+
<check switch="+Rkp_19747" label="possible occurrence of KP 19747"/>
602604
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
603605
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
604606
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>

0 commit comments

Comments
 (0)