parent
edbd4f6e81
commit
dee2ad8756
|
@ -1481,9 +1481,17 @@ bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2
|
||||||
if (!tok_str_eq) {
|
if (!tok_str_eq) {
|
||||||
const Token* refTok1 = followReferences(tok1, errors);
|
const Token* refTok1 = followReferences(tok1, errors);
|
||||||
const Token* refTok2 = followReferences(tok2, errors);
|
const Token* refTok2 = followReferences(tok2, errors);
|
||||||
if (refTok1 != tok1 || refTok2 != tok2)
|
if (refTok1 != tok1 || refTok2 != tok2) {
|
||||||
|
if (refTok1 && !refTok1->varId() && refTok2 && !refTok2->varId()) { // complex reference expression
|
||||||
|
const Token *start = refTok1, *end = refTok2;
|
||||||
|
if (!precedes(start, end))
|
||||||
|
std::swap(start, end);
|
||||||
|
if (isExpressionChanged(start, start, end, nullptr, cpp))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return isSameExpression(cpp, macro, refTok1, refTok2, library, pure, followVar, errors);
|
return isSameExpression(cpp, macro, refTok1, refTok2, library, pure, followVar, errors);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (tok1->varId() != tok2->varId() || !tok_str_eq || tok1->originalName() != tok2->originalName()) {
|
if (tok1->varId() != tok2->varId() || !tok_str_eq || tok1->originalName() != tok2->originalName()) {
|
||||||
if ((Token::Match(tok1,"<|>") && Token::Match(tok2,"<|>")) ||
|
if ((Token::Match(tok1,"<|>") && Token::Match(tok2,"<|>")) ||
|
||||||
(Token::Match(tok1,"<=|>=") && Token::Match(tok2,"<=|>="))) {
|
(Token::Match(tok1,"<=|>=") && Token::Match(tok2,"<=|>="))) {
|
||||||
|
|
|
@ -4890,6 +4890,15 @@ private:
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n" // #10337
|
||||||
|
" int b[2] = { 1, 2 };\n"
|
||||||
|
" int idx = 0;\n"
|
||||||
|
" int& i = b[idx];\n"
|
||||||
|
" idx++;\n"
|
||||||
|
" i = b[idx];\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void trac1132() {
|
void trac1132() {
|
||||||
|
|
Loading…
Reference in New Issue