Fix issue 10049: False positive: generic reverse valueflow analysis (#2959)
This commit is contained in:
parent
ad7a53e88c
commit
2541b6034f
|
@ -160,7 +160,7 @@ struct ReverseTraversal {
|
|||
settings);
|
||||
}
|
||||
// Assignment to
|
||||
} else if (lhsAction.matches()) {
|
||||
} else if (lhsAction.matches() && !assignTok->astOperand2()->hasKnownValue()) {
|
||||
const std::string info = "Assignment to '" + assignTok->expressionString() + "'";
|
||||
ValuePtr<Analyzer> a = analyzer->reanalyze(assignTok->astOperand2(), info);
|
||||
if (a) {
|
||||
|
|
|
@ -710,6 +710,18 @@ private:
|
|||
" return 1/a->x;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #10049
|
||||
check("int f(int argc) {\n"
|
||||
" int quotient, remainder;\n"
|
||||
" remainder = argc % 2;\n"
|
||||
" argc = 2;\n"
|
||||
" quotient = argc;\n"
|
||||
" if (quotient != 0) \n"
|
||||
" return quotient;\n"
|
||||
" return remainder;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nanInArithmeticExpression() {
|
||||
|
|
Loading…
Reference in New Issue