From bfbb2eef6c75e426d25f3a998986ae4484addb67 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Mon, 16 Feb 2026 09:38:15 +0000 Subject: [PATCH] C++: Add a test showing that we infer a lower and upper bound for parameters of enum types. --- .../SimpleRangeAnalysis/lowerBound.expected | 1 + .../SimpleRangeAnalysis/nrOfBounds.expected | 7 +++++++ .../rangeanalysis/SimpleRangeAnalysis/test.c | 12 ++++++++++++ .../SimpleRangeAnalysis/upperBound.expected | 1 + 4 files changed, 21 insertions(+) diff --git a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected index d1daa65e0f0..b5aec1e8328 100644 --- a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected +++ b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected @@ -1086,6 +1086,7 @@ | test.c:970:12:970:12 | y | 256 | | test.c:971:9:971:9 | x | 2147483647 | | test.c:972:9:972:9 | y | 256 | +| test.c:985:7:985:7 | e | -2147483648 | | test.cpp:10:7:10:7 | b | -2147483648 | | test.cpp:11:5:11:5 | x | -2147483648 | | test.cpp:13:10:13:10 | x | -2147483648 | diff --git a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/nrOfBounds.expected b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/nrOfBounds.expected index 8a02673e988..050b67f3350 100644 --- a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/nrOfBounds.expected +++ b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/nrOfBounds.expected @@ -4937,6 +4937,13 @@ estimateNrOfBounds | test.c:970:18:970:20 | 512 | 1.0 | | test.c:971:9:971:9 | x | 1.0 | | test.c:972:9:972:9 | y | 1.0 | +| test.c:977:9:977:11 | 1 | 1.0 | +| test.c:978:9:978:11 | 2 | 1.0 | +| test.c:979:9:979:11 | 4 | 1.0 | +| test.c:980:9:980:11 | 8 | 1.0 | +| test.c:981:9:981:12 | 16 | 1.0 | +| test.c:985:7:985:7 | (int)... | 1.0 | +| test.c:985:7:985:7 | e | 1.0 | | test.cpp:9:11:9:12 | - ... | 1.0 | | test.cpp:9:12:9:12 | 1 | 1.0 | | test.cpp:10:7:10:7 | (bool)... | 1.0 | diff --git a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c index d394eb637ab..71f28e8f605 100644 --- a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c +++ b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c @@ -972,3 +972,15 @@ void test_overflow() { out(y); } } + +enum MY_ENUM_2 { + A = 0x1, + B = 0x2, + C = 0x4, + D = 0x8, + E = 0x10 +}; + +void test_enum(enum MY_ENUM_2 e) { + out(e); +} \ No newline at end of file diff --git a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected index a483f2cba93..e414265ca39 100644 --- a/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected +++ b/cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected @@ -1086,6 +1086,7 @@ | test.c:970:12:970:12 | y | 256 | | test.c:971:9:971:9 | x | 2147483647 | | test.c:972:9:972:9 | y | 256 | +| test.c:985:7:985:7 | e | 2147483647 | | test.cpp:10:7:10:7 | b | 2147483647 | | test.cpp:11:5:11:5 | x | 2147483647 | | test.cpp:13:10:13:10 | x | 2147483647 |