Fixed #1095 (Non-obvious error message: Dangerous usage of erase)
This commit is contained in:
parent
f5f8d857c1
commit
72bf1c1dbe
|
@ -253,7 +253,7 @@ void CheckStl::eraseCheckLoop(const Token *it)
|
||||||
// Error message for bad iterator usage..
|
// Error message for bad iterator usage..
|
||||||
void CheckStl::eraseError(const Token *tok)
|
void CheckStl::eraseError(const Token *tok)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::error, "erase", "Dangerous usage of erase\nAfter erase has been used the iterator may be invalid so dereferencing it or comparing it with other iterator is invalid.");
|
reportError(tok, Severity::error, "erase", "Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,7 @@ private:
|
||||||
" foo.erase(it);\n"
|
" foo.erase(it);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (error) Dangerous usage of erase\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.\n", errout.str());
|
||||||
|
|
||||||
check("for (it = foo.begin(); it != foo.end(); ++it)\n"
|
check("for (it = foo.begin(); it != foo.end(); ++it)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -279,7 +279,8 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" foo.erase(it);\n"
|
" foo.erase(it);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Dangerous usage of erase\n[test.cpp:7]: (error) Dangerous usage of erase\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.\n"
|
||||||
|
"[test.cpp:7]: (error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.\n", errout.str());
|
||||||
|
|
||||||
check("void f(std::list<int> &ints)\n"
|
check("void f(std::list<int> &ints)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue