diff --git a/test/testother.cpp b/test/testother.cpp index 352d8416d..3a159be53 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -147,6 +147,7 @@ private: TEST_CASE(comparisonOfBoolWithInt5); TEST_CASE(duplicateIf); + TEST_CASE(duplicateIf1); // ticket 3689 TEST_CASE(duplicateBranch); TEST_CASE(duplicateExpression1); TEST_CASE(duplicateExpression2); // ticket #2730 @@ -4098,6 +4099,31 @@ private: ASSERT_EQUALS("", errout.str()); } + void duplicateIf1() { // ticket 3689 ( avoid false positive ) + + check("#define INT32_MAX 0x7fffffffLL\n" + "#define INT48_MAX 0x7fffffffffffLL\n" + "#define INT64_MAX 0x7fffffffffffffffLL\n" + "int fitInt(long long int nValue){\n" + " if( nValue < INT32_MAX )\n" + " {\n" + " return 32;\n" + " }\n" + " if( nValue < INT48_MAX )\n" + " {\n" + " return 48;\n" + " }\n" + " else if( nValue < INT64_MAX )\n" + " {\n" + " return 64;\n" + " } else\n" + " {\n" + " return -1;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void duplicateExpression2() { // ticket #2730 check("int main()\n" "{\n"