* Fix #10357 FP stlcstrParam due to incorrect overload resolution * Variable shadowing
This commit is contained in:
parent
a50452517d
commit
24e9859158
|
@ -5041,7 +5041,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
|
||||||
for (std::multimap<std::string, const Function *>::const_iterator it = scope->functionMap.find(tok->str()); it != scope->functionMap.cend() && it->first == tok->str(); ++it) {
|
for (std::multimap<std::string, const Function *>::const_iterator it = scope->functionMap.find(tok->str()); it != scope->functionMap.cend() && it->first == tok->str(); ++it) {
|
||||||
const Function *func = it->second;
|
const Function *func = it->second;
|
||||||
if (!isCall || args == func->argCount() ||
|
if (!isCall || args == func->argCount() ||
|
||||||
(func->isVariadic() && args >= (func->argCount() - 1)) ||
|
(func->isVariadic() && args >= (func->minArgCount() - 1)) ||
|
||||||
(args < func->argCount() && args >= func->minArgCount())) {
|
(args < func->argCount() && args >= func->minArgCount())) {
|
||||||
matches.push_back(func);
|
matches.push_back(func);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6580,8 +6580,8 @@ static void valueFlowLibraryFunction(Token *tok, const std::string &returnValue,
|
||||||
productParams(argValues, [&](const std::unordered_map<nonneg int, ValueFlow::Value>& arg) {
|
productParams(argValues, [&](const std::unordered_map<nonneg int, ValueFlow::Value>& arg) {
|
||||||
ProgramMemory pm{};
|
ProgramMemory pm{};
|
||||||
for (const auto& p : arg) {
|
for (const auto& p : arg) {
|
||||||
const Token* tok = lookupVarId[p.first];
|
const Token* varTok = lookupVarId[p.first];
|
||||||
pm.setValue(tok, p.second);
|
pm.setValue(varTok, p.second);
|
||||||
}
|
}
|
||||||
MathLib::bigint result = 0;
|
MathLib::bigint result = 0;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
|
@ -3830,6 +3830,13 @@ private:
|
||||||
" return ref.c_str();\n"
|
" return ref.c_str();\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Dangerous usage of c_str(). The value returned by c_str() is invalid after this call.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (error) Dangerous usage of c_str(). The value returned by c_str() is invalid after this call.\n", errout.str());
|
||||||
|
|
||||||
|
check("void f(const wchar_t* w, int i = 0, ...);\n" // #10357
|
||||||
|
"void f(const std::string& s, int i = 0);\n"
|
||||||
|
"void g(const std::wstring& p) {\n"
|
||||||
|
" f(p.c_str());\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uselessCalls() {
|
void uselessCalls() {
|
||||||
|
|
Loading…
Reference in New Issue