Fixed #1095 (Non-obvious error message: Dangerous usage of erase)

This commit is contained in:
Daniel Marjamäki 2009-12-21 20:49:16 +01:00
parent f5f8d857c1
commit 72bf1c1dbe
2 changed files with 4 additions and 3 deletions

View File

@ -253,7 +253,7 @@ void CheckStl::eraseCheckLoop(const Token *it)
// Error message for bad iterator usage..
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.");
}

View File

@ -269,7 +269,7 @@ private:
" foo.erase(it);\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"
"{\n"
@ -279,7 +279,8 @@ private:
"{\n"
" foo.erase(it);\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"
"{\n"