Fixed #6284 (Token::Match called with varid 0. Constants)
This commit is contained in:
parent
0ca088d0cf
commit
7021cb2c6b
|
@ -2803,7 +2803,11 @@ void Tokenizer::setVarId()
|
|||
if (rhs)
|
||||
continue;
|
||||
|
||||
if (tok3->isLiteral() || (tok3->isName() && (variableId.find(tok3->str()) != variableId.end())) || tok3->isOp() || notstart.find(tok3->str()) != notstart.end()) {
|
||||
if (tok3->isLiteral() ||
|
||||
(tok3->isName() && (variableId.find(tok3->str()) != variableId.end())) ||
|
||||
tok3->isOp() ||
|
||||
tok3->str() == "(" ||
|
||||
notstart.find(tok3->str()) != notstart.end()) {
|
||||
decl = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5425,6 +5425,40 @@ private:
|
|||
ASSERT_EQUALS("return doSomething ( X ) , 0 ;", tokenizeAndStringify(code, false));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "const int x(1);"
|
||||
"const int y(2);"
|
||||
"const int z((x+1)*y);"
|
||||
"f(z);";
|
||||
ASSERT_EQUALS("f ( 4 ) ;", tokenizeAndStringify(code, true));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "const int x(1);"
|
||||
"const int y(2);"
|
||||
"const int z((x+1)*y);"
|
||||
"f(&z);";
|
||||
ASSERT_EQUALS("const int z ( 4 ) ; f ( & z ) ;", tokenizeAndStringify(code, true));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "const bool x(true);"
|
||||
"const bool y(!x);"
|
||||
"f(y);";
|
||||
ASSERT_EQUALS("f ( false ) ;", tokenizeAndStringify(code, true));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "const bool x(true);"
|
||||
"const bool y(!x);"
|
||||
"f(&y);";
|
||||
ASSERT_EQUALS("const bool y ( false ) ; f ( & y ) ;", tokenizeAndStringify(code, true));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyInitVar2() {
|
||||
|
|
Loading…
Reference in New Issue