Fixed #5890 - crash: wesnoth desktop_util.cpp / unicode.hpp.

This commit is contained in:
orbitcowboy 2014-05-29 02:58:18 +02:00
parent e5ae575ace
commit e9144d1a78
2 changed files with 10 additions and 0 deletions

View File

@ -3189,6 +3189,8 @@ void CheckOther::checkRedundantCopy()
continue;
const Token* tok = startTok->next()->astOperand2();
if (!tok)
continue;
if (!Token::Match(tok->previous(), "%var% ("))
continue;
if (!Token::Match(tok->link(), ") )| ;")) // bailout for usage like "const A a = getA()+3"

View File

@ -6358,6 +6358,14 @@ private:
" }\n"
"}\n");
TODO_ASSERT_EQUALS("", "[test.cpp:7]: (performance, inconclusive) Use const reference for 'temp' to avoid unnecessary data copying.\n", errout.str());
// #5890 - crash: wesnoth desktop_util.cpp / unicode.hpp
check_redundant_copy("typedef std::vector<char> X;\n"
"X f<X>(const X &in) {\n"
" const X s = f<X>(in);\n"
" return f<X>(s);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void checkNegativeShift() {