Skip to content

Commit 090b7e8

Browse files
committed
Fix #14193 FP knownConditionTrueFalse for loop references to container elements
1 parent e8d37ed commit 090b7e8

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

lib/astutils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,8 @@ static const Token * followVariableExpression(const Settings& settings, const To
12031203
return tok;
12041204
if (hasUnknownVars(varTok))
12051205
return tok;
1206+
//if (astIsRangeBasedForDecl(var->nameToken()))
1207+
// return tok;
12061208
if (var->isVolatile())
12071209
return tok;
12081210
if (!var->isLocal() && !var->isConst())

test/testother.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8004,6 +8004,15 @@ class TestOther : public TestFixture {
80048004
" }\n"
80058005
"}\n");
80068006
ASSERT_EQUALS("", errout_str());
8007+
8008+
check("void f(const std::vector<int>& v) {\n"
8009+
" for (const int& r1 : v) {\n"
8010+
" for (const int& r2 : v) {\n"
8011+
" if (&r1 == &r2) {}\n"
8012+
" }\n"
8013+
" }\n"
8014+
"}\n");
8015+
ASSERT_EQUALS("", errout_str());
80078016
}
80088017

80098018
void duplicateExpressionTernary() { // #6391

0 commit comments

Comments
 (0)