Fixed #3939: Support ****foo++;
This commit is contained in:
parent
c3a65dca40
commit
b156c727b0
|
@ -238,11 +238,18 @@ void CheckOther::clarifyStatement()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "[{};] * %var%")) {
|
if (Token::Match(tok, "* %var%")) {
|
||||||
tok = tok->tokAt(3);
|
const Token *tok2=tok->previous();
|
||||||
|
|
||||||
|
while (Token::Match(tok2, "*"))
|
||||||
|
tok2=tok2->previous();
|
||||||
|
|
||||||
|
if (Token::Match(tok2, "[{};]")) {
|
||||||
|
tok = tok->tokAt(2);
|
||||||
while (tok) {
|
while (tok) {
|
||||||
if (tok->str() == "[")
|
if (tok->str() == "[")
|
||||||
tok = tok->link()->next();
|
tok = tok->link()->next();
|
||||||
|
|
||||||
if (Token::Match(tok, ".|:: %var%")) {
|
if (Token::Match(tok, ".|:: %var%")) {
|
||||||
if (tok->strAt(2) == "(")
|
if (tok->strAt(2) == "(")
|
||||||
tok = tok->linkAt(2)->next();
|
tok = tok->linkAt(2)->next();
|
||||||
|
@ -256,6 +263,7 @@ void CheckOther::clarifyStatement()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CheckOther::clarifyStatementError(const Token *tok)
|
void CheckOther::clarifyStatementError(const Token *tok)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4040,6 +4040,29 @@ private:
|
||||||
" bar(*c++);\n"
|
" bar(*c++);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("char*** f(char*** c) {\n"
|
||||||
|
" ***c++;\n"
|
||||||
|
" return c;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
|
||||||
|
|
||||||
|
check("char** f(char*** c) {\n"
|
||||||
|
" **c[5]--;\n"
|
||||||
|
" return **c;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
|
||||||
|
|
||||||
|
check("char*** f(char*** c) {\n"
|
||||||
|
" (***c)++;\n"
|
||||||
|
" return c;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void *f(char** c) {\n"
|
||||||
|
" bar(**c++);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// clarify conditions with = and comparison
|
// clarify conditions with = and comparison
|
||||||
|
|
Loading…
Reference in New Issue