Skip to content

Commit bfbb2ee

Browse files
committed
C++: Add a test showing that we infer a lower and upper bound for parameters of enum types.
1 parent 84be851 commit bfbb2ee

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@
10861086
| test.c:970:12:970:12 | y | 256 |
10871087
| test.c:971:9:971:9 | x | 2147483647 |
10881088
| test.c:972:9:972:9 | y | 256 |
1089+
| test.c:985:7:985:7 | e | -2147483648 |
10891090
| test.cpp:10:7:10:7 | b | -2147483648 |
10901091
| test.cpp:11:5:11:5 | x | -2147483648 |
10911092
| test.cpp:13:10:13:10 | x | -2147483648 |

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/nrOfBounds.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4937,6 +4937,13 @@ estimateNrOfBounds
49374937
| test.c:970:18:970:20 | 512 | 1.0 |
49384938
| test.c:971:9:971:9 | x | 1.0 |
49394939
| test.c:972:9:972:9 | y | 1.0 |
4940+
| test.c:977:9:977:11 | 1 | 1.0 |
4941+
| test.c:978:9:978:11 | 2 | 1.0 |
4942+
| test.c:979:9:979:11 | 4 | 1.0 |
4943+
| test.c:980:9:980:11 | 8 | 1.0 |
4944+
| test.c:981:9:981:12 | 16 | 1.0 |
4945+
| test.c:985:7:985:7 | (int)... | 1.0 |
4946+
| test.c:985:7:985:7 | e | 1.0 |
49404947
| test.cpp:9:11:9:12 | - ... | 1.0 |
49414948
| test.cpp:9:12:9:12 | 1 | 1.0 |
49424949
| test.cpp:10:7:10:7 | (bool)... | 1.0 |

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,3 +972,15 @@ void test_overflow() {
972972
out(y);
973973
}
974974
}
975+
976+
enum MY_ENUM_2 {
977+
A = 0x1,
978+
B = 0x2,
979+
C = 0x4,
980+
D = 0x8,
981+
E = 0x10
982+
};
983+
984+
void test_enum(enum MY_ENUM_2 e) {
985+
out(e);
986+
}

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@
10861086
| test.c:970:12:970:12 | y | 256 |
10871087
| test.c:971:9:971:9 | x | 2147483647 |
10881088
| test.c:972:9:972:9 | y | 256 |
1089+
| test.c:985:7:985:7 | e | 2147483647 |
10891090
| test.cpp:10:7:10:7 | b | 2147483647 |
10901091
| test.cpp:11:5:11:5 | x | 2147483647 |
10911092
| test.cpp:13:10:13:10 | x | 2147483647 |

0 commit comments

Comments
 (0)