Fix issue 8730: Dont follow variables with unknown symbols (#1374)
This commit is contained in:
parent
399a90c00e
commit
90a29d986b
|
@ -228,6 +228,8 @@ static const Token * followVariableExpression(const Token * tok, bool cpp, const
|
|||
// Recognized as a variable but the declaration is unknown
|
||||
} else if (tok2->varId() > 0) {
|
||||
return tok;
|
||||
} else if(tok2->tokType() == Token::eName && !Token::Match(tok2, "sizeof|decltype|typeof") && !tok2->function()) {
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
return varTok;
|
||||
|
|
|
@ -4266,6 +4266,20 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(bool c) {\n"
|
||||
" const bool b = a;\n"
|
||||
" if(c) { a = false; } \n"
|
||||
" if(b && !a) { }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" bool x = a;\n"
|
||||
" dostuff();\n"
|
||||
" if (x && a) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" const bool b = g();\n"
|
||||
" if (!b && g()) {}\n"
|
||||
|
|
Loading…
Reference in New Issue