diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 927fd2334..22309d401 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -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) diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 05e00724f..552a7e3f2 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -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" "}");