Skip to content

Commit dd79199

Browse files
committed
Merge branch 'topic/493' into 'master'
Add detector for KP-19915 Closes #493 See merge request eng/libadalang/langkit-query-language!494
2 parents 4bd8f77 + 852a6f2 commit dd79199

File tree

7 files changed

+30
-0
lines changed

7 files changed

+30
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@check(help="occurrence of KP 19915",
2+
message="occurrence of KP 19915")
3+
fun kp_19915(node) =
4+
|" Search for `'Class'Max_Size_In_Storage_Elements`.
5+
node is AttributeRef(f_prefix: prefix@AttributeRef)
6+
when node.f_attribute.p_name_is("Max_Size_In_Storage_Elements")
7+
and prefix.f_attribute.p_name_is("Class")

lkql_checker/share/lkql/kp/kp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"kp_19749": "24.*,25.*",
2727
"kp_19753": "21.*,22.*,23.*,24.1,24.2,25.1",
2828
"kp_19824": "25.*",
29+
"kp_19915": "25.1",
2930
"kp_ob03_009": "19.*",
3031
"kp_p226_024": "7.1.*,7.2.*,7.3.*,7.4.1,7.4.2,7.4.3",
3132
"kp_q309_014": "7.1.*,7.2.*,7.3.*,7.4.*,17.*",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
procedure Main is
2+
type T is tagged null record;
3+
type U is new T with record I: Integer; end record;
4+
5+
A : Long_Integer := T'Max_Size_In_Storage_Elements; -- NOFLAG
6+
B : T'Class := U'(I => 1); -- NOFLAG
7+
8+
Size : Long_Integer := T'Class'Max_Size_In_Storage_Elements; -- FLAG
9+
begin
10+
null;
11+
end;
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
main.adb:8:27: rule violation: occurrence of KP 19915
2+
8 | Size : Long_Integer := T'Class'Max_Size_In_Storage_Elements; -- FLAG
3+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
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_19915
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
@@ -92,6 +92,7 @@ testsuite_driver: No output file generated by gnatcheck
9292
<check switch="+Rkp_19749" label="possible occurrence of KP 19749"/>
9393
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
9494
<check switch="+Rkp_19824" label="possible occurrence of KP 19824"/>
95+
<check switch="+Rkp_19915" label="occurrence of KP 19915"/>
9596
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
9697
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
9798
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>
@@ -609,6 +610,7 @@ testsuite_driver: No output file generated by gnatcheck
609610
<check switch="+Rkp_19749" label="possible occurrence of KP 19749"/>
610611
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
611612
<check switch="+Rkp_19824" label="possible occurrence of KP 19824"/>
613+
<check switch="+Rkp_19915" label="occurrence of KP 19915"/>
612614
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
613615
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
614616
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>

0 commit comments

Comments
 (0)