Fixed false positive in new stringLiteralWrite checker

This commit is contained in:
Daniel Marjamäki 2015-05-03 12:34:27 +02:00
parent 6b80e61934
commit e837bad01d
2 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ namespace {
void CheckString::stringLiteralWrite()
{
for (const Token* tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (!tok->variable())
if (!tok->variable() || !tok->variable()->isPointer())
continue;
const Token *str = tok->getValueTokenMinStrSize();
if (!str)

View File

@ -111,8 +111,8 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (error) Modifying string literal directly or indirectly is undefined behaviour\n", errout.str());
check("void f() {\n"
" char *abc = \"abc\";\n"
" if (*abc == 'a'){}\n"
" QString abc = \"abc\";\n"
" abc[0] = 'a';\n"
"}");
ASSERT_EQUALS("", errout.str());
}