File tree Expand file tree Collapse file tree
lkql_checker/share/lkql/kp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ @check(help="possible occurrence of KP 20273",
2+ message="possible occurrence of KP 20273")
3+ fun kp_20273(node) =
4+ |" Flag any iterated association. A Constraint_Error exception
5+ |" might incorrectly be raised when evaluating an array
6+ |" aggregate written using the Ada 2022 iterated component
7+ |" association syntax and known to be empty at compile time.
8+ node is IteratedAssoc
Original file line number Diff line number Diff line change 1+ pragma Ada_2022;
2+
3+ procedure Main is
4+ type Class_Settings_Type is record
5+ C : Boolean;
6+ end record ;
7+
8+ type Class_Index_Type is range 1 .. 10 ;
9+
10+ type Obj_Settings_List_Type is
11+ array (Class_Index_Type range <>) of Class_Settings_Type;
12+
13+ Obj_Settings_List : constant Obj_Settings_List_Type := [];
14+
15+ type Class_Type is record
16+ C2 : Boolean;
17+ end record ;
18+
19+ function Create_Obj (Setttings : Class_Settings_Type) return Class_Type is
20+ begin
21+ return (C2 => True);
22+ end Create_Obj ;
23+
24+ Class_List : array (Obj_Settings_List'Range ) of Class_Type :=
25+ [for I in Obj_Settings_List'Range => -- FLAG
26+ Create_Obj (Setttings => Obj_Settings_List (I))];
27+ begin
28+ null ;
29+ end Main ;
Original file line number Diff line number Diff line change 1+ project Prj is
2+ end Prj;
Original file line number Diff line number Diff line change 1+ main.adb:25:7: rule violation: possible occurrence of KP 20273
2+ 25 | [for I in Obj_Settings_List'Range => -- FLAG
3+ | _______^
4+ 26 || Create_Obj (Setttings => Obj_Settings_List (I))];
5+ ||_______________________________________________________^
6+
Original file line number Diff line number Diff line change 1+ driver : checker
2+ rule_name : kp_20273
3+ project : prj.gpr
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ testsuite_driver: No output file generated by gnatcheck
103103 <check switch="+Rkp_20186" label="possible occurrence of KP 20186"/>
104104 <check switch="+Rkp_20227" label="possible occurrence of KP 20227"/>
105105 <check switch="+Rkp_20229" label="possible occurrence of KP 20229"/>
106+ <check switch="+Rkp_20273" label="possible occurrence of KP 20273"/>
106107 <check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
107108 <check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
108109 <check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>
@@ -631,6 +632,7 @@ testsuite_driver: No output file generated by gnatcheck
631632 <check switch="+Rkp_20186" label="possible occurrence of KP 20186"/>
632633 <check switch="+Rkp_20227" label="possible occurrence of KP 20227"/>
633634 <check switch="+Rkp_20229" label="possible occurrence of KP 20229"/>
635+ <check switch="+Rkp_20273" label="possible occurrence of KP 20273"/>
634636 <check switch="+Rkp_ob03_009" label="possible occurrence of KP OB03-009"/>
635637 <check switch="+Rkp_p226_024" label="possible occurrence of KP P226-024 - global analysis required"/>
636638 <check switch="+Rkp_q309_014" label="possible occurrence of KP Q309-014"/>
You can’t perform that action at this time.
0 commit comments