Fix issue 8743: FP when derefencing iterators (#1376)

This commit is contained in:
Paul Fultz II 2018-09-12 10:33:53 -05:00 committed by Daniel Marjamäki
parent 90a29d986b
commit eb07280075
2 changed files with 9 additions and 0 deletions

View File

@ -457,6 +457,8 @@ static const Token * getIteratorExpression(const Token * tok)
{ {
if (!tok) if (!tok)
return nullptr; return nullptr;
if (tok->isUnaryOp("*"))
return nullptr;
if (!tok->isName()) { if (!tok->isName()) {
const Token *iter1 = getIteratorExpression(tok->astOperand1()); const Token *iter1 = getIteratorExpression(tok->astOperand1());
if (iter1) if (iter1)

View File

@ -709,6 +709,13 @@ private:
" if (begin(a).x == begin(b).x) {}\n" " if (begin(a).x == begin(b).x) {}\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" std::list<int*> a;\n"
" std::list<int*> b;\n"
" if (*a.begin() == *b.begin()) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void iteratorSameExpression() { void iteratorSameExpression() {