ValueFlow: Set value for ::

This commit is contained in:
Daniel Marjamäki 2019-10-19 21:08:59 +02:00
parent 574141a492
commit 9a2b71494f
2 changed files with 11 additions and 0 deletions

View File

@ -1047,6 +1047,10 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
}
}
}
else if (Token::Match(parent, ":: %name%") && parent->astOperand2() == tok) {
setTokenValue(parent, value, settings);
}
}
static void setTokenValueCast(Token *parent, const ValueType &valueType, const ValueFlow::Value &value, const Settings *settings)

View File

@ -331,6 +331,13 @@ private:
ASSERT_EQUALS((int)('a'), valueOfTok("x='a';", "'a'").intvalue);
ASSERT_EQUALS((int)('\n'), valueOfTok("x='\\n';", "'\\n'").intvalue);
ASSERT_EQUALS(0xFFFFFFFF00000000, valueOfTok("x=0xFFFFFFFF00000000;","18446744069414584320U").intvalue); // #7701
// scope
{
const char code[] = "namespace N { enum E {e0,e1}; }\n"
"void foo() { x = N::e1; }";
ASSERT_EQUALS(1, valueOfTok(code, "::").intvalue);
}
}
void valueFlowString() {