diff --git a/lib/checkother.cpp b/lib/checkother.cpp index f3d5bbaa8..c88d2d127 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1978,7 +1978,7 @@ void CheckOther::checkConstantFunctionParameter() // namespace and add them to the pattern. There are // streams for example (however it seems strange with // const stream parameter). - if (Token::Match(tok, "std :: string|wstring")) { + if (Token::Match(tok, "std :: string|wstring !!::")) { passedByValueError(tok, var->name()); } else if (Token::Match(tok, "std :: %type% <") && !Token::simpleMatch(tok->linkAt(3), "> ::")) { passedByValueError(tok, var->name()); diff --git a/test/testother.cpp b/test/testother.cpp index e5a21c0c8..05936db23 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1577,6 +1577,9 @@ private: testPassedByValue("void f(const std::string str) {}"); ASSERT_EQUALS("[test.cpp:1]: (performance) Function parameter 'str' should be passed by reference.\n", errout.str()); + testPassedByValue("void f(const std::string::size_type x) {}"); + ASSERT_EQUALS("", errout.str()); + testPassedByValue("class Foo;\nvoid f(const Foo foo) {}"); ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'foo' should be passed by reference.\n", errout.str());