From ae6201d28932f54eb605f84de7e67e7f73eee4d1 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 23 Jul 2012 01:41:20 -0700 Subject: [PATCH] Fixed false positive "Parameter 'x' is passed as a value" for types like std::vector::size_type (#3986) --- lib/checkother.cpp | 2 +- test/testother.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b07c4ace5..43829c89b 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1741,7 +1741,7 @@ void CheckOther::checkConstantFunctionParameter() // const stream parameter). if (Token::Match(tok, "std :: string|wstring")) { passedByValueError(tok, var->name()); - } else if (Token::Match(tok, "std :: %type% <")) { + } else if (Token::Match(tok, "std :: %type% <") && !Token::Match(tok->linkAt(3), "> ::")) { passedByValueError(tok, var->name()); } else if (var->type() || symbolDatabase->isClassOrStruct(tok->str())) { // Check if type is a struct or class. passedByValueError(tok, var->name()); diff --git a/test/testother.cpp b/test/testother.cpp index 0ae96fbc7..41a217139 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -969,6 +969,9 @@ private: testPassedByValue("void f(const std::vector v) {}"); ASSERT_EQUALS("[test.cpp:1]: (performance) Function parameter 'v' should be passed by reference.\n", errout.str()); + testPassedByValue("void f(const std::vector::size_type s) {}"); + ASSERT_EQUALS("", errout.str()); + testPassedByValue("void f(const std::vector &v) {}"); ASSERT_EQUALS("", errout.str());