Fixed false positive #5824: Variables that might be used for va_start() must not be passed by reference.
This commit is contained in:
parent
adcc8b1634
commit
d3a567bf96
|
@ -1976,6 +1976,9 @@ void CheckOther::checkConstantFunctionParameter()
|
|||
if (!var || !var->isArgument() || !var->isClass() || !var->isConst() || var->isPointer() || var->isArray() || var->isReference())
|
||||
continue;
|
||||
|
||||
if (var->scope()->function->arg->link()->strAt(-1) == ".")
|
||||
continue; // references could not be used as va_start parameters (#5824)
|
||||
|
||||
const Token* const tok = var->typeStartToken();
|
||||
// TODO: False negatives. This pattern only checks for string.
|
||||
// Investigate if there are other classes in the std
|
||||
|
|
|
@ -1632,7 +1632,8 @@ private:
|
|||
testPassedByValue("void f(const std::map<std::string,int> v) {}");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (performance) Function parameter 'v' should be passed by reference.\n", errout.str());
|
||||
|
||||
testPassedByValue("void f(const std::streamoff pos) {}");
|
||||
// #5824
|
||||
testPassedByValue("void log(const std::string& file, int line, const std::string& function, const std::string str, ...) {}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue