Skip to content

Commit d18be81

Browse files
committed
Merge branch 'topic/kp_20227' into 'master'
Add detector for KP 20227 Closes #590 See merge request eng/libadalang/langkit-query-language!590
2 parents 4d40f1b + d5e80b6 commit d18be81

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@check(help="possible occurrence of KP 20227",
2+
message="possible occurrence of KP 20227")
3+
fun kp_20227(node) =
4+
|" Flags unchecked union types.
5+
node is BaseTypeDecl(p_has_aspect("unchecked_union"): true)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
procedure Main is
2+
type R_1 (B : Boolean) is record -- FLAG
3+
case B is
4+
when True =>
5+
I : Integer;
6+
7+
when False =>
8+
C : Character;
9+
end case;
10+
end record;
11+
12+
pragma Unchecked_Union (R_1);
13+
14+
type R_2 (B : Boolean) is record -- FLAG
15+
case B is
16+
when True =>
17+
I : Integer;
18+
19+
when False =>
20+
C : Character;
21+
end case;
22+
end record
23+
with Unchecked_Union;
24+
25+
type R_3 (B : Boolean) is record -- NOFLAG
26+
case B is
27+
when True =>
28+
I : Integer;
29+
30+
when False =>
31+
C : Character;
32+
end case;
33+
end record;
34+
35+
subtype S_R_1 is R_1; -- FLAG
36+
type D_R_1 is new R_1; -- FLAG
37+
begin
38+
null;
39+
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
main.adb:2:9: rule violation: possible occurrence of KP 20227
2+
2 | type R_1 (B : Boolean) is record -- FLAG
3+
| ^^^
4+
5+
main.adb:14:9: rule violation: possible occurrence of KP 20227
6+
14 | type R_2 (B : Boolean) is record -- FLAG
7+
| ^^^
8+
9+
main.adb:35:12: rule violation: possible occurrence of KP 20227
10+
35 | subtype S_R_1 is R_1; -- FLAG
11+
| ^^^^^
12+
13+
main.adb:36:9: rule violation: possible occurrence of KP 20227
14+
36 | type D_R_1 is new R_1; -- FLAG
15+
| ^^^^^
16+
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_20227
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
@@ -101,6 +101,7 @@ testsuite_driver: No output file generated by gnatcheck
101101
<check switch="+Rkp_20112" label="possible occurrence of KP 20112"/>
102102
<check switch="+Rkp_20113" label="possible occurrence of KP 20113"/>
103103
<check switch="+Rkp_20186" label="possible occurrence of KP 20186"/>
104+
<check switch="+Rkp_20227" label="possible occurrence of KP 20227"/>
104105
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
105106
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
106107
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>
@@ -627,6 +628,7 @@ testsuite_driver: No output file generated by gnatcheck
627628
<check switch="+Rkp_20112" label="possible occurrence of KP 20112"/>
628629
<check switch="+Rkp_20113" label="possible occurrence of KP 20113"/>
629630
<check switch="+Rkp_20186" label="possible occurrence of KP 20186"/>
631+
<check switch="+Rkp_20227" label="possible occurrence of KP 20227"/>
630632
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
631633
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
632634
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>

0 commit comments

Comments
 (0)