Skip to content

Commit 91eae0e

Browse files
committed
Ensure expression type is not null in KP-S814-034
1 parent 4c43bd8 commit 91eae0e

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

lkql_checker/share/lkql/kp/KP-S814-034.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import stdlib
44
fun kp_s814_034(node) =
55
|" Flag array aggregates with an others choice if the array component type is a
66
|" record type that has a string subcomponent.
7-
node is Aggregate(p_is_subaggregate(): false, p_expression_type(): t)
7+
node is Aggregate(p_is_subaggregate(): false, p_expression_type(): t@BaseTypeDecl)
88
when
99
# Check that the aggregate is not a nested array aggregate
1010
not node.p_is_subaggregate() and

testsuite/tests/checks/KP-S814-034/p.adb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
procedure P is
2+
-- Ensure aggregates with no type don't trigger any error
3+
type Example_Enum is (A, B, C);
4+
for Example_Enum use (A => 0, B => 1, C => 2); -- NOFLAG
5+
26
Max_Error_Length : constant := 8;
37
subtype Str is String (1 .. Max_Error_Length);
48

59
S_Init : constant Str := "INIT ";
610

7-
type Rec is record
11+
type Rec is tagged record
812
Text : Str;
913
end record;
1014

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
p.adb:22:18: rule violation: possible occurrence of KP S814-034
2-
22 | A : Arr := (others => (others => S_Init)); -- FLAG
1+
p.adb:26:18: rule violation: possible occurrence of KP S814-034
2+
26 | A : Arr := (others => (others => S_Init)); -- FLAG
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5-
p.adb:23:22: rule violation: possible occurrence of KP S814-034
6-
23 | M_A : M_Arr := (others => (others => R_Init)); -- FLAG
5+
p.adb:27:22: rule violation: possible occurrence of KP S814-034
6+
27 | M_A : M_Arr := (others => (others => R_Init)); -- FLAG
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88

9-
p.adb:24:22: rule violation: possible occurrence of KP S814-034
10-
24 | D_A : D_Arr := (others => (Text => S_Init, I => 2)); -- FLAG
9+
p.adb:28:22: rule violation: possible occurrence of KP S814-034
10+
28 | D_A : D_Arr := (others => (Text => S_Init, I => 2)); -- FLAG
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
p.adb:28:6: rule violation: possible occurrence of KP S814-034
14-
28 | (3 => (Text => "INVALID "), others => (Text => "OTHERS ")); -- FLAG
13+
p.adb:32:6: rule violation: possible occurrence of KP S814-034
14+
32 | (3 => (Text => "INVALID "), others => (Text => "OTHERS ")); -- FLAG
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

0 commit comments

Comments
 (0)