Fixed #5941 (ValueFlow: Wrong value in subfunction under ?)
This commit is contained in:
parent
1b5d127373
commit
54aede9086
|
@ -1212,9 +1212,9 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger,
|
||||||
if (Token::Match(tok2, "%varid% !!=", varid2)) {
|
if (Token::Match(tok2, "%varid% !!=", varid2)) {
|
||||||
for (std::list<ValueFlow::Value>::const_iterator val = argvalues.begin(); val != argvalues.end(); ++val)
|
for (std::list<ValueFlow::Value>::const_iterator val = argvalues.begin(); val != argvalues.end(); ++val)
|
||||||
setTokenValue(const_cast<Token*>(tok2), *val);
|
setTokenValue(const_cast<Token*>(tok2), *val);
|
||||||
} else if (tok2->str() == "{") {
|
} else if (tok2->str() == "{" || tok2->str() == "?") {
|
||||||
if (settings->debugwarnings)
|
if (settings->debugwarnings)
|
||||||
bailout(tokenlist, errorLogger, tok2, "parameter " + arg->nameToken()->str());
|
bailout(tokenlist, errorLogger, tok2, "parameter " + arg->nameToken()->str() + ", at '" + tok2->str() + "'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4418,7 +4418,7 @@ private:
|
||||||
"[test.cpp:20] -> [test.cpp:1]: (style, inconclusive) The function parameter 'A' hides a typedef with the same name.\n"
|
"[test.cpp:20] -> [test.cpp:1]: (style, inconclusive) The function parameter 'A' hides a typedef with the same name.\n"
|
||||||
"[test.cpp:21] -> [test.cpp:1]: (style, inconclusive) The variable 'A' hides a typedef with the same name.\n"
|
"[test.cpp:21] -> [test.cpp:1]: (style, inconclusive) The variable 'A' hides a typedef with the same name.\n"
|
||||||
"[test.cpp:24] -> [test.cpp:1]: (style, inconclusive) The typedef 'A' hides a typedef with the same name.\n"
|
"[test.cpp:24] -> [test.cpp:1]: (style, inconclusive) The typedef 'A' hides a typedef with the same name.\n"
|
||||||
"[test.cpp:24]: (debug) ValueFlow bailout: parameter a\n", errout.str());
|
"[test.cpp:24]: (debug) ValueFlow bailout: parameter a, at '{'\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyTypedef36() {
|
void simplifyTypedef36() {
|
||||||
|
|
|
@ -892,6 +892,14 @@ private:
|
||||||
code = "void f1(int x) { a=(abc)x; }\n"
|
code = "void f1(int x) { a=(abc)x; }\n"
|
||||||
"void f2(int y) { f1(123); }\n";
|
"void f2(int y) { f1(123); }\n";
|
||||||
ASSERT_EQUALS(true, testValueOfX(code, 1U, 123));
|
ASSERT_EQUALS(true, testValueOfX(code, 1U, 123));
|
||||||
|
|
||||||
|
code = "void f1(int x) {\n"
|
||||||
|
" x ?\n"
|
||||||
|
" 1024 / x :\n"
|
||||||
|
" 0; }\n"
|
||||||
|
"void f2() { f1(0); }";
|
||||||
|
ASSERT_EQUALS(true, testValueOfX(code, 2U, 0));
|
||||||
|
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue