Fixed #7979 (crash (nr 2): CheckFunctions::checkIgnoredReturnValue())
This commit is contained in:
parent
392a06a44b
commit
7d8af7bdca
|
@ -160,6 +160,18 @@ void CheckFunctions::checkIgnoredReturnValue()
|
||||||
if (Token::Match(tok, "%var%|(|, {"))
|
if (Token::Match(tok, "%var%|(|, {"))
|
||||||
tok = tok->linkAt(1);
|
tok = tok->linkAt(1);
|
||||||
|
|
||||||
|
if (Token::Match(tok->previous(), "%name% (")) {
|
||||||
|
bool semicolon = false;
|
||||||
|
for (const Token *tok2 = tok->tokAt(2); tok2 && tok2->str() != ")"; tok2 = tok2->next()) {
|
||||||
|
if (tok2->str() == ";")
|
||||||
|
semicolon = true;
|
||||||
|
else if (Token::Match(tok2, "[({]"))
|
||||||
|
tok2 = tok2->link();
|
||||||
|
}
|
||||||
|
if (semicolon)
|
||||||
|
tok = tok->link();
|
||||||
|
}
|
||||||
|
|
||||||
if (tok->varId() || !Token::Match(tok, "%name% ("))
|
if (tok->varId() || !Token::Match(tok, "%name% ("))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -912,6 +912,12 @@ private:
|
||||||
" int x({mystrcmp(a,b)});\n"
|
" int x({mystrcmp(a,b)});\n"
|
||||||
"}", "test.cpp", &settings2);
|
"}", "test.cpp", &settings2);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #7979 - code is not well configured
|
||||||
|
check("void foo() {\n"
|
||||||
|
" DEBUG(x(); mystrcmp(a,b););\n"
|
||||||
|
"}", "test.cpp", &settings2);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue