Fix 10522: FP: derefInvalidIterator when using emplace with 1 argument (#3482)
This commit is contained in:
parent
c7e13d0e0b
commit
71809044bd
|
@ -460,6 +460,9 @@ Token* astParentSkipParens(Token* tok)
|
||||||
return parent;
|
return parent;
|
||||||
if (parent->link() != nextAfterAstRightmostLeaf(tok))
|
if (parent->link() != nextAfterAstRightmostLeaf(tok))
|
||||||
return parent;
|
return parent;
|
||||||
|
if (Token::Match(parent->previous(), "%name% (") ||
|
||||||
|
(Token::simpleMatch(parent->previous(), "> (") && parent->previous()->link()))
|
||||||
|
return parent;
|
||||||
return astParentSkipParens(parent);
|
return astParentSkipParens(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4098,6 +4098,12 @@ private:
|
||||||
" return *it;\n"
|
" return *it;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("int f(std::vector<int> &vect) {\n"
|
||||||
|
" const int &v = *vect.emplace(vect.end());\n"
|
||||||
|
" return v;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void dereferenceInvalidIterator2() {
|
void dereferenceInvalidIterator2() {
|
||||||
|
|
Loading…
Reference in New Issue