Fix 10785: False positive: constParameter when using member pointer (#3807)
This commit is contained in:
parent
d528555002
commit
260d155bb6
|
@ -541,12 +541,15 @@ const Token* getParentLifetime(const Token* tok)
|
||||||
{
|
{
|
||||||
if (!tok)
|
if (!tok)
|
||||||
return tok;
|
return tok;
|
||||||
const Variable* var = tok->variable();
|
// Skipping checking for variable if its a pointer-to-member
|
||||||
// TODO: Call getLifetimeVariable for deeper analysis
|
if (!Token::simpleMatch(tok->previous(), ". *")) {
|
||||||
if (!var)
|
const Variable* var = tok->variable();
|
||||||
return tok;
|
// TODO: Call getLifetimeVariable for deeper analysis
|
||||||
if (var->isLocal() || var->isArgument())
|
if (!var)
|
||||||
return tok;
|
return tok;
|
||||||
|
if (var->isLocal() || var->isArgument())
|
||||||
|
return tok;
|
||||||
|
}
|
||||||
const Token* parent = getParentMember(tok);
|
const Token* parent = getParentMember(tok);
|
||||||
if (parent != tok)
|
if (parent != tok)
|
||||||
return getParentLifetime(parent);
|
return getParentLifetime(parent);
|
||||||
|
|
|
@ -2676,6 +2676,13 @@ private:
|
||||||
" s.g(0, PC);\n"
|
" s.g(0, PC);\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #10785
|
||||||
|
check("template <class T, class C>\n"
|
||||||
|
"struct d {\n"
|
||||||
|
" T& g(C& c, T C::*f) { return c.*f; }\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void constParameterCallback() {
|
void constParameterCallback() {
|
||||||
|
|
Loading…
Reference in New Issue