Robert Reif: Fixed #1139 (false negative: CheckOther::postIncrement() only finds at most one problem)
This commit is contained in:
parent
fe74c65c89
commit
5a89cc3259
|
@ -1612,8 +1612,6 @@ void CheckOther::postIncrement()
|
||||||
// Is the variable a class?
|
// Is the variable a class?
|
||||||
else if (Token::findmatch(_tokenizer->tokens(), classDef.c_str()))
|
else if (Token::findmatch(_tokenizer->tokens(), classDef.c_str()))
|
||||||
postIncrementError(tok2, tok2->strAt(1), (std::string("++") == tok2->strAt(2)));
|
postIncrementError(tok2, tok2->strAt(1), (std::string("++") == tok2->strAt(2)));
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1409,6 +1409,17 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (possible style) Pre-Incrementing variable 'it' is preferred to Post-Incrementing\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (possible style) Pre-Incrementing variable 'it' is preferred to Post-Incrementing\n", errout.str());
|
||||||
|
|
||||||
|
checkpostIncrementDecrement("void f1()\n"
|
||||||
|
"{\n"
|
||||||
|
" std::list<int>::iterator it;\n"
|
||||||
|
" for (it = ab.begin(); it != ab.end(); it++)\n"
|
||||||
|
" ;\n"
|
||||||
|
" for (it = ab.begin(); it != ab.end(); it++)\n"
|
||||||
|
" ;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (possible style) Pre-Incrementing variable 'it' is preferred to Post-Incrementing\n"
|
||||||
|
"[test.cpp:6]: (possible style) Pre-Incrementing variable 'it' is preferred to Post-Incrementing\n", errout.str());
|
||||||
|
|
||||||
checkpostIncrementDecrement("void f2()\n"
|
checkpostIncrementDecrement("void f2()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" std::list<int>::iterator it;\n"
|
" std::list<int>::iterator it;\n"
|
||||||
|
@ -1416,6 +1427,17 @@ private:
|
||||||
" ;\n"
|
" ;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (possible style) Pre-Decrementing variable 'it' is preferred to Post-Decrementing\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (possible style) Pre-Decrementing variable 'it' is preferred to Post-Decrementing\n", errout.str());
|
||||||
|
|
||||||
|
checkpostIncrementDecrement("void f2()\n"
|
||||||
|
"{\n"
|
||||||
|
" std::list<int>::iterator it;\n"
|
||||||
|
" for (it = ab.end(); it != ab.begin(); it--)\n"
|
||||||
|
" ;\n"
|
||||||
|
" for (it = ab.end(); it != ab.begin(); it--)\n"
|
||||||
|
" ;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (possible style) Pre-Decrementing variable 'it' is preferred to Post-Decrementing\n"
|
||||||
|
"[test.cpp:6]: (possible style) Pre-Decrementing variable 'it' is preferred to Post-Decrementing\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void postIncrementDecrementClass()
|
void postIncrementDecrementClass()
|
||||||
|
|
Loading…
Reference in New Issue