Skip to content

Commit e2dc7ed

Browse files
committed
Fix Kp detector TA30-032
This change improves subtypes support.
1 parent 0e74f58 commit e2dc7ed

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lkql_checker/share/lkql/kp/KP-TA30-032.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import stdlib
55

66
fun range_length(t) =
7-
match t.f_type_def.f_indices.f_types[1]
7+
match t.p_base_subtype().f_type_def.f_indices.f_types[1]
88
| u@UnconstrainedArrayIndex => stdlib.number_of_values(
99
u.f_subtype_name.p_referenced_decl()
1010
)

testsuite/tests/checks/KP-TA30-032/simple.ads

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ package Simple is
1212
type Element_Array is array (Index_Range range <>) of Element;
1313
Null_Element_Array : Element_Array (1 .. 0); -- FLAG
1414

15+
subtype Sub_Element_Array is Element_Array;
16+
Null_Sub_Element_Array : Sub_Element_Array (1 .. 0); -- FLAG
17+
1518
end Simple;

testsuite/tests/checks/KP-TA30-032/test.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ simple.ads:13:4: rule violation: possible occurrence of KP TA30-032
66
13 | Null_Element_Array : Element_Array (1 .. 0); -- FLAG
77
| ^^^^^^^^^^^^^^^^^^
88

9+
simple.ads:16:4: rule violation: possible occurrence of KP TA30-032
10+
16 | Null_Sub_Element_Array : Sub_Element_Array (1 .. 0); -- FLAG
11+
| ^^^^^^^^^^^^^^^^^^^^^^
12+

0 commit comments

Comments
 (0)