fix 2846 (false positive for auto_ptr check with container element)

This commit is contained in:
seb777 2011-06-20 23:02:05 +02:00
parent 47a15b6486
commit 172903cde4
2 changed files with 10 additions and 1 deletions

View File

@ -1138,7 +1138,7 @@ void CheckStl::checkAutoPointer()
tok3 = tok3->next();
}
tok3 = tok3->previous()->previous();
if (Token::Match(tok3, "] )"))
if (Token::Match(tok3->previous(), "[ ] )"))
{
autoPointerArrayError(tok2->next());
}

View File

@ -1321,6 +1321,15 @@ private:
void autoPointer()
{
// ticket 2846
check("void f()\n"
"{\n"
" std::vector<int*> vec;\n"
" vec.push_back(new int(3));\n"
" std::auto_ptr<int> ret(vec[0]);\n"
"};\n");
ASSERT_EQUALS("", errout.str());
// ticket 2839
check("template <class MUTEX_TYPE>\n"
"class Guarded\n"