Skip to content

Commit

Permalink
Fix and enhance the 'Bit_Records_Without_Layout_Definition' rule
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoGGuerrier committed Jan 6, 2025
1 parent 1f60a15 commit 4f2aaa0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TODO: move this function to libadalang
fun lal_is_mod_type(n) =
n.f_type_expr.p_designated_type_decl().f_type_def is ModIntTypeDef
n.f_type_expr.p_designated_type_decl().p_root_type() is TypeDecl(f_type_def: ModIntTypeDef)

@check(message="bit record without layout definition",
category="Style", subcategory="Portability")
Expand Down
10 changes: 10 additions & 0 deletions testsuite/tests/checks/bit_records/bit.ads
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package Bit is
type My_Mod is mod 8;
subtype X is My_Mod;
type D is new My_Mod;

type Rec1 is record -- NOFLAG
I : My_Mod;
Expand All @@ -17,4 +19,12 @@ package Bit is
type Rec2_PA is record -- FLAG
I : My_Mod;
end record with Pack, Size => 32;

type Rec3 is record -- FLAG
I : X;
end record with Pack;

type Rec4 is record -- FLAG
I : D;
end record with Pack;
end Bit;
16 changes: 12 additions & 4 deletions testsuite/tests/checks/bit_records/test.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
bit.ads:11:9: rule violation: bit record without layout definition
11 | type Rec2_PP is record -- FLAG
bit.ads:13:9: rule violation: bit record without layout definition
13 | type Rec2_PP is record -- FLAG
| ^^^^^^^

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

bit.ads:23:9: rule violation: bit record without layout definition
23 | type Rec3 is record -- FLAG
| ^^^^

bit.ads:27:9: rule violation: bit record without layout definition
27 | type Rec4 is record -- FLAG
| ^^^^

0 comments on commit 4f2aaa0

Please sign in to comment.