Fixed #5731 (False positive with opposite conditions)

This commit is contained in:
Daniel Marjamäki 2014-04-27 10:21:20 +02:00
parent 7317785e32
commit bde6698bcd
2 changed files with 13 additions and 0 deletions

View File

@ -3321,6 +3321,9 @@ void CheckOther::oppositeInnerCondition()
nonlocal |= (var && (!var->isLocal() || var->isStatic()));
// TODO: if var is pointer check what it points at
nonlocal |= (var && var->isPointer());
} else if (cond->isName()) {
// varid is 0. this is possibly a nonlocal variable..
nonlocal |= (cond->astParent() && cond->astParent()->isConstOp());
}
}

View File

@ -392,6 +392,16 @@ private:
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
// #5731 - fp when undeclared variable is used
check("void f() {\n"
" if (x == -1){\n"
" x = do_something();\n"
" if (x != -1) {}\n"
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void emptyBrackets() {