Skip to content

Commit 75373b2

Browse files
committed
Add detector for KP-19824
1 parent b50037a commit 75373b2

File tree

8 files changed

+75
-0
lines changed

8 files changed

+75
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import kp_v404_040_internal
2+
3+
@check(help="possible occurrence of KP 19824",
4+
message="possible occurrence of KP 19824")
5+
fun kp_19824(node) =
6+
|" Flag 'Valid attribute applied to a floating-point component of a
7+
|" composite type subject to a Scalar_Storage_Order aspect/clause.
8+
kp_v404_040_internal.check(node)

lkql_checker/share/lkql/kp/kp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"kp_19747": "24.1,24.2",
2626
"kp_19749": "24.*,25.*",
2727
"kp_19753": "21.*,22.*,23.*,24.1,24.2,25.1",
28+
"kp_19824": "25.*",
2829
"kp_ob03_009": "19.*",
2930
"kp_p226_024": "7.1.*,7.2.*,7.3.*,7.4.1,7.4.2,7.4.3",
3031
"kp_q309_014": "7.1.*,7.2.*,7.3.*,7.4.*,17.*",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
with System;
2+
3+
procedure P is
4+
type Angle_Type is new Float range 0.0 .. 359.99;
5+
-- Derived floating point type
6+
7+
-- Record type with floating point elements.
8+
type My_Record_Type is record
9+
Az : Angle_Type;
10+
El : Angle_Type;
11+
end record;
12+
13+
-- Big endian byte order
14+
for My_Record_Type'Bit_Order use System.High_Order_First;
15+
for My_Record_Type'Scalar_Storage_Order use System.High_Order_First;
16+
17+
type My_Record_Type2 is record
18+
Az : Angle_Type;
19+
El : Angle_Type;
20+
end record;
21+
22+
My_Record : My_Record_Type := (1.1, 2.2);
23+
My_Record2 : My_Record_Type2 := (1.1, 2.2);
24+
25+
Is_Valid : Boolean := My_Record.Az'Valid; -- FLAG
26+
27+
begin
28+
Is_Valid := My_Record2.Az'Valid; -- NOFLAG
29+
end P;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
with System;
2+
3+
procedure P2 is
4+
type Angle_Type is new Float range 0.0 .. 359.99;
5+
-- Derived floating point type
6+
7+
-- Array type with floating point elements.
8+
type My_Array_Type is array (1 .. 2) of Angle_Type;
9+
10+
-- Big endian byte order
11+
for My_Array_Type'Scalar_Storage_Order use System.High_Order_First;
12+
13+
type My_Array_Type2 is array (1 .. 2) of Angle_Type;
14+
15+
My_Array : My_Array_Type := (1.1, 2.2);
16+
My_Array2 : My_Array_Type2 := (1.1, 2.2);
17+
18+
Is_Valid : Boolean := My_Array (1)'Valid; -- FLAG
19+
20+
begin
21+
Is_Valid := My_Array2 (1)'Valid; -- NOFLAG
22+
end P2;
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
p.adb:25:26: rule violation: possible occurrence of KP 19824
2+
25 | Is_Valid : Boolean := My_Record.Az'Valid; -- FLAG
3+
| ^^^^^^^^^^^^^^^^^^
4+
5+
p2.adb:18:26: rule violation: possible occurrence of KP 19824
6+
18 | Is_Valid : Boolean := My_Array (1)'Valid; -- FLAG
7+
| ^^^^^^^^^^^^^^^^^^
8+
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_19824
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
@@ -91,6 +91,7 @@ testsuite_driver: No output file generated by gnatcheck
9191
<check switch="+Rkp_19747" label="possible occurrence of KP 19747"/>
9292
<check switch="+Rkp_19749" label="possible occurrence of KP 19749"/>
9393
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
94+
<check switch="+Rkp_19824" label="possible occurrence of KP 19824"/>
9495
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
9596
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
9697
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>
@@ -607,6 +608,7 @@ testsuite_driver: No output file generated by gnatcheck
607608
<check switch="+Rkp_19747" label="possible occurrence of KP 19747"/>
608609
<check switch="+Rkp_19749" label="possible occurrence of KP 19749"/>
609610
<check switch="+Rkp_19753" label="possible occurrence of KP 19753"/>
611+
<check switch="+Rkp_19824" label="possible occurrence of KP 19824"/>
610612
<check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
611613
<check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
612614
<check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>

0 commit comments

Comments
 (0)