Skip to content

Commit ae1614c

Browse files
committed
Merge branch 'topic/kp_20186' into 'master'
Add detector for KP 20186 Closes #583 See merge request eng/libadalang/langkit-query-language!581
2 parents eb5fe61 + 3483aa7 commit ae1614c

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@check(help="possible occurrence of KP 20186",
2+
message="possible occurrence of KP 20186")
3+
fun kp_20186(node) =
4+
|" Flag private type declarations which full type is a scalar type with a
5+
|" size representation clause.
6+
node is BaseTypeDecl(p_is_private(): true) when
7+
node.p_full_view() is t@BaseTypeDecl(
8+
p_is_scalar_type(): true,
9+
p_has_aspect("size"): true
10+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package Main is
2+
type Pub_Range is range 1 .. 2 with Size => 8; -- NOFLAG
3+
type Priv_Range is private; -- FLAG
4+
subtype Priv_Range_Sub is Priv_Range; -- NOFLAG
5+
type Priv_Float_Range is private; -- FLAG
6+
type Priv_Enum is private; -- FLAG
7+
type Priv_Range_No_Size is private; -- NOFLAG
8+
type Priv_Arr is private; -- NOFLAG
9+
private
10+
type Priv_Range is range 1 .. 2 with Size => 8;
11+
type Priv_Float_Range is digits 8 with Size => 64;
12+
type Priv_Enum is (A, B, C) with Size => 8;
13+
type Priv_Range_No_Size is range 1 .. 2;
14+
type Priv_Arr is array (1 .. 2) of Integer with Size => 64;
15+
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
main.ads:3:9: rule violation: possible occurrence of KP 20186
2+
3 | type Priv_Range is private; -- FLAG
3+
| ^^^^^^^^^^
4+
5+
main.ads:5:9: rule violation: possible occurrence of KP 20186
6+
5 | type Priv_Float_Range is private; -- FLAG
7+
| ^^^^^^^^^^^^^^^^
8+
9+
main.ads:6:9: rule violation: possible occurrence of KP 20186
10+
6 | type Priv_Enum is private; -- FLAG
11+
| ^^^^^^^^^
12+
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_20186
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
@@ -99,6 +99,7 @@ testsuite_driver: No output file generated by gnatcheck
9999
<check switch="+Rkp_20023" label="possible occurrence of KP 20023"/>
100100
<check switch="+Rkp_20089" label="possible occurrence of KP 20089"/>
101101
<check switch="+Rkp_20113" label="possible occurrence of KP 20113"/>
102+
<check switch="+Rkp_20186" label="possible occurrence of KP 20186"/>
102103
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
103104
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
104105
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>
@@ -623,6 +624,7 @@ testsuite_driver: No output file generated by gnatcheck
623624
<check switch="+Rkp_20023" label="possible occurrence of KP 20023"/>
624625
<check switch="+Rkp_20089" label="possible occurrence of KP 20089"/>
625626
<check switch="+Rkp_20113" label="possible occurrence of KP 20113"/>
627+
<check switch="+Rkp_20186" label="possible occurrence of KP 20186"/>
626628
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
627629
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
628630
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>

0 commit comments

Comments
 (0)