Skip to content

Commit 3f7ecdb

Browse files
Add tests for #6796, #12896
1 parent 72547b3 commit 3f7ecdb

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/testcondition.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6472,6 +6472,19 @@ class TestCondition : public TestFixture {
64726472
" if (INT_MAX > ll * 8) {}\n"
64736473
"}\n");
64746474
ASSERT_EQUALS("", errout_str());
6475+
6476+
check("bool f(int a, int b) {\n" / #12896
6477+
" if (a < INT_MIN && b > INT_MAX)\n"
6478+
" return true;\n"
6479+
" return false;\n"
6480+
"}\n"
6481+
"bool g(int x) {\n" // #6796
6482+
" return (x > INT_MAX) ? true : false;\n"
6483+
"}\n");
6484+
ASSERT_EQUALS("[test.cpp:2:13]: (style) Comparing expression of type 'signed int' against value -2147483648. Condition is always false. [compareValueOutOfTypeRangeError]\n"
6485+
"[test.cpp:2:28]: (style) Comparing expression of type 'signed int' against value 2147483647. Condition is always false. [compareValueOutOfTypeRangeError]\n"
6486+
"[test.cpp:7:17]: (style) Comparing expression of type 'signed int' against value 2147483647. Condition is always false. [compareValueOutOfTypeRangeError]\n",
6487+
errout_str());
64756488
}
64766489

64776490
void knownConditionCast() {

0 commit comments

Comments
 (0)