Fixed #5731 (False positive with opposite conditions)
This commit is contained in:
parent
7317785e32
commit
bde6698bcd
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue