Use Variable::valueType instead of Variable::typeStartToken in auto variables

This commit is contained in:
Daniel Marjamäki 2018-06-24 08:25:19 +02:00
parent 2beeca3ca2
commit cde63c7573
2 changed files with 6 additions and 1 deletions

View File

@ -73,7 +73,7 @@ static bool isRefPtrArg(const Token *tok)
static bool isNonReferenceArg(const Token *tok)
{
const Variable *var = tok->variable();
return (var && var->isArgument() && !var->isReference() && (var->isPointer() || var->typeStartToken()->isStandardType() || var->type()));
return (var && var->isArgument() && !var->isReference() && (var->isPointer() || var->valueType()->type >= ValueType::Type::CONTAINER || var->type()));
}
static bool isAutoVar(const Token *tok)

View File

@ -274,6 +274,11 @@ private:
"}");
ASSERT_EQUALS("[test.cpp:2]: (style) Assignment of function parameter has no effect outside the function.\n", errout.str());
check("void foo(std::string s) {\n"
" s = foo(b);\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (style) Assignment of function parameter has no effect outside the function.\n", errout.str());
check("void foo(char* p) {\n" // don't warn for self assignment, there is another warning for this
" p = p;\n"
"}");