* Fix #11223 checkLibraryFunction treats "auto" as type * Use utility function
This commit is contained in:
parent
883908b439
commit
9efedd6be9
|
@ -2264,6 +2264,11 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token * tok)
|
|||
if (r.first)
|
||||
return r;
|
||||
}
|
||||
if (astIsRangeBasedForDecl(var->nameToken()) && astIsContainer(var->nameToken()->astParent()->astOperand2())) { // range-based for
|
||||
const ValueType* vt = var->nameToken()->astParent()->astOperand2()->valueType();
|
||||
if (vt && vt->containerTypeToken)
|
||||
return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) };
|
||||
}
|
||||
}
|
||||
return {var->typeStartToken(), var->typeEndToken()->next()};
|
||||
} else if (Token::simpleMatch(tok, "return")) {
|
||||
|
|
|
@ -1900,6 +1900,12 @@ private:
|
|||
"void g() { C::f(); }\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(const std::vector<std::string>& v) {\n" // #11223
|
||||
" for (const auto& s : v)\n"
|
||||
" s.find(\"\");\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function s.find() is not used.\n", errout.str());
|
||||
|
||||
settings.severity = severity_old;
|
||||
settings.checkLibrary = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue