added testcase for ticket 3689

This commit is contained in:
Ettl Martin 2012-05-14 09:57:30 +02:00
parent 895ee61ed5
commit 8a7b141246
1 changed files with 26 additions and 0 deletions

View File

@ -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"