Skip to content

Commit 4f2aaa0

Browse files
committed
Fix and enhance the 'Bit_Records_Without_Layout_Definition' rule
1 parent 1f60a15 commit 4f2aaa0

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

lkql_checker/share/lkql/bit_records_without_layout_definition.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TODO: move this function to libadalang
22
fun lal_is_mod_type(n) =
3-
n.f_type_expr.p_designated_type_decl().f_type_def is ModIntTypeDef
3+
n.f_type_expr.p_designated_type_decl().p_root_type() is TypeDecl(f_type_def: ModIntTypeDef)
44

55
@check(message="bit record without layout definition",
66
category="Style", subcategory="Portability")

testsuite/tests/checks/bit_records/bit.ads

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package Bit is
22
type My_Mod is mod 8;
3+
subtype X is My_Mod;
4+
type D is new My_Mod;
35

46
type Rec1 is record -- NOFLAG
57
I : My_Mod;
@@ -17,4 +19,12 @@ package Bit is
1719
type Rec2_PA is record -- FLAG
1820
I : My_Mod;
1921
end record with Pack, Size => 32;
22+
23+
type Rec3 is record -- FLAG
24+
I : X;
25+
end record with Pack;
26+
27+
type Rec4 is record -- FLAG
28+
I : D;
29+
end record with Pack;
2030
end Bit;
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
bit.ads:11:9: rule violation: bit record without layout definition
2-
11 | type Rec2_PP is record -- FLAG
1+
bit.ads:13:9: rule violation: bit record without layout definition
2+
13 | type Rec2_PP is record -- FLAG
33
| ^^^^^^^
44

5-
bit.ads:17:9: rule violation: bit record without layout definition
6-
17 | type Rec2_PA is record -- FLAG
5+
bit.ads:19:9: rule violation: bit record without layout definition
6+
19 | type Rec2_PA is record -- FLAG
77
| ^^^^^^^
88

9+
bit.ads:23:9: rule violation: bit record without layout definition
10+
23 | type Rec3 is record -- FLAG
11+
| ^^^^
12+
13+
bit.ads:27:9: rule violation: bit record without layout definition
14+
27 | type Rec4 is record -- FLAG
15+
| ^^^^
16+

0 commit comments

Comments
 (0)