File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
testsuite/tests/checks/integer_as_enum Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ fun integer_types_as_enum(node) =
70
70
|" X := 2;
71
71
|" Y := Y + 1;
72
72
|" end Proc;
73
- node is TypeDecl (p_is_int_type(): true)
73
+ node is ConcreteTypeDecl (p_is_int_type(): true)
74
74
when not [t for t in types() if t == node]
75
75
and not [t for t in instantiations() if t == node]
76
76
and not [t for t in arithmetic_ops() if t == node]
Original file line number Diff line number Diff line change
1
+ procedure Generics is
2
+ generic
3
+ type T is range <>; -- NOFLAG
4
+ package Pkg is
5
+ -- T is never used as an integer type so in theory it could be flagged
6
+ -- by this rule. However, we don't want to flag formal types.
7
+ type U is range 1 .. 3 ; -- FLAG
8
+ -- make sure that concrete type declarations inside generics are still
9
+ -- flagged though.
10
+ end Pkg ;
11
+
12
+ package My_Pkg is new Pkg (Integer);
13
+ begin
14
+ null ;
15
+ end Generics ;
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ bit.adb:2:9: rule violation: integer type may be replaced by an enumeration
2
2
2 | type Enum is mod 2 ** 8; -- FLAG
3
3
| ^^^^
4
4
5
+ generics.adb:7:12: rule violation: integer type may be replaced by an enumeration
6
+ 7 | type U is range 1 .. 3; -- FLAG
7
+ | ^
8
+
5
9
op.adb:2:9: rule violation: integer type may be replaced by an enumeration
6
10
2 | type Enum is range 1 .. 3; -- FLAG
7
11
| ^^^^
You can’t perform that action at this time.
0 commit comments