parent
3874c546cc
commit
33c55f77a8
|
@ -1037,6 +1037,9 @@ static bool compareKnownValue(const Token * const tok1, const Token * const tok2
|
|||
{
|
||||
static const auto isKnownFn = std::mem_fn(&ValueFlow::Value::isKnown);
|
||||
|
||||
if ((tok1->variable() && tok1->variable()->isStatic()) || (tok2->variable() && tok2->variable()->isStatic()))
|
||||
return false;
|
||||
|
||||
const auto v1 = std::find_if(tok1->values().begin(), tok1->values().end(), isKnownFn);
|
||||
if (v1 == tok1->values().end()) {
|
||||
return false;
|
||||
|
|
|
@ -5593,6 +5593,14 @@ private:
|
|||
" std::vector<int> v = b ? bar : baz;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(bool q) {\n" // #9570
|
||||
" static int a = 0;\n"
|
||||
" static int b = 0;\n"
|
||||
" int& x = q ? a : b;\n"
|
||||
" ++x;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void duplicateExpressionTemplate() { // #6930
|
||||
|
|
Loading…
Reference in New Issue