Fix issue 8736: Iterators to containers from different expressions (a.begin().x == b.begin().x) (#1370)
This commit is contained in:
parent
a5064b00b6
commit
f7e7e9bd3c
|
@ -467,9 +467,9 @@ static const Token * getIteratorExpression(const Token * tok)
|
||||||
if (iter2)
|
if (iter2)
|
||||||
return iter2;
|
return iter2;
|
||||||
} else if (Token::Match(tok, "begin|cbegin|rbegin|crbegin|end|cend|rend|crend (")) {
|
} else if (Token::Match(tok, "begin|cbegin|rbegin|crbegin|end|cend|rend|crend (")) {
|
||||||
if (Token::Match(tok->previous(), ". %name% ( )"))
|
if (Token::Match(tok->previous(), ". %name% ( ) !!."))
|
||||||
return tok->previous()->astOperand1();
|
return tok->previous()->astOperand1();
|
||||||
if (Token::Match(tok, "%name% ( !!)"))
|
if (Token::Match(tok, "%name% ( !!)") && !Token::simpleMatch(tok->linkAt(1), ") ."))
|
||||||
return tok->next()->astOperand2();
|
return tok->next()->astOperand2();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -705,6 +705,12 @@ private:
|
||||||
" if(f().begin()+1 == f().end()+1) {}\n"
|
" if(f().begin()+1 == f().end()+1) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" if (a.begin().x == b.begin().x) {}\n"
|
||||||
|
" if (begin(a).x == begin(b).x) {}\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void iteratorSameExpression() {
|
void iteratorSameExpression() {
|
||||||
|
|
Loading…
Reference in New Issue