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)
|
||||
return tok;
|
||||
const Variable* var = tok->variable();
|
||||
// TODO: Call getLifetimeVariable for deeper analysis
|
||||
if (!var)
|
||||
return tok;
|
||||
if (var->isLocal() || var->isArgument())
|
||||
return tok;
|
||||
// Skipping checking for variable if its a pointer-to-member
|
||||
if (!Token::simpleMatch(tok->previous(), ". *")) {
|
||||
const Variable* var = tok->variable();
|
||||
// TODO: Call getLifetimeVariable for deeper analysis
|
||||
if (!var)
|
||||
return tok;
|
||||
if (var->isLocal() || var->isArgument())
|
||||
return tok;
|
||||
}
|
||||
const Token* parent = getParentMember(tok);
|
||||
if (parent != tok)
|
||||
return getParentLifetime(parent);
|
||||
|
|
|
@ -2676,6 +2676,13 @@ private:
|
|||
" s.g(0, PC);\n"
|
||||
"};\n");
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue