Fixed false positive autovarInvalidDeallocation if deallocting result of member function (#6551)

This commit is contained in:
PKEuS 2015-11-11 16:59:13 +01:00
parent 630ba1086c
commit a8cf63239a
2 changed files with 14 additions and 0 deletions

View File

@ -76,6 +76,13 @@ bool CheckAutoVariables::isAutoVar(const Token *tok)
return false;
}
if (Token::Match(tok, "%name% .|::")) {
do {
tok = tok->tokAt(2);
} while (Token::Match(tok, "%name% .|::"));
if (Token::Match(tok, "%name% ("))
return false;
}
return true;
}

View File

@ -592,6 +592,13 @@ private:
" }\n"
"};");
ASSERT_EQUALS("", errout.str());
// #6551
check("bool foo( ) {\n"
" SwTxtFld * pTxtFld = GetFldTxtAttrAt();\n"
" delete static_cast<SwFmtFld*>(&pTxtFld->GetAttr());\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void testinvaliddealloc_C() {