You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
" void modify() { for (const auto& e : m) e.second->i = 0; }\n"
8196
+
"};\n"
8197
+
"void f(T& t) {\n"
8198
+
" const S* p = t.get(\"abc\");\n"
8199
+
" const int o = p->i;\n"
8200
+
" t.modify();\n"
8201
+
" if (p->i == o) {}\n"
8202
+
"}\n");
8203
+
ASSERT_EQUALS("", errout_str());
8204
+
8205
+
check("struct S { int i; };\n"
8206
+
" struct T {\n"
8207
+
" std::vector<S*> m;\n"
8208
+
" void modify() { for (auto e : m) e->i = 0; }\n"
8209
+
"};\n"
8210
+
"void f(T& t) {\n"
8211
+
" const S* p = t.m[0];\n"
8212
+
" const int o = p->i;\n"
8213
+
" t.modify();\n"
8214
+
" if (p->i == o) {}\n"
8215
+
"}\n");
8216
+
ASSERT_EQUALS("", errout_str());
8217
+
}
8218
+
8189
8219
void duplicateExpressionLoop() {
8190
8220
check("void f() {\n"
8191
8221
" int a = 1;\n"
@@ -8897,8 +8927,7 @@ class TestOther : public TestFixture {
8897
8927
" if (i == j) {}\n"
8898
8928
"}");
8899
8929
ASSERT_EQUALS(
8900
-
"[test.cpp:4:9] -> [test.cpp:3:9]: (style, inconclusive) Same expression used in consecutive assignments of 'i' and 'j'. [duplicateAssignExpression]\n"
8901
-
"[test.cpp:3:14] -> [test.cpp:4:14] -> [test.cpp:6:11]: (style) The comparison 'i == j' is always true because 'i' and 'j' represent the same value. [knownConditionTrueFalse]\n",
8930
+
"[test.cpp:4:9] -> [test.cpp:3:9]: (style, inconclusive) Same expression used in consecutive assignments of 'i' and 'j'. [duplicateAssignExpression]\n",
8902
8931
errout_str());
8903
8932
8904
8933
check("struct A { int x; int y; };"
@@ -8910,8 +8939,7 @@ class TestOther : public TestFixture {
8910
8939
" if (i == a.x) {}\n"
8911
8940
"}");
8912
8941
ASSERT_EQUALS(
8913
-
"[test.cpp:4:9] -> [test.cpp:3:9]: (style, inconclusive) Same expression used in consecutive assignments of 'i' and 'j'. [duplicateAssignExpression]\n"
8914
-
"[test.cpp:3:14] -> [test.cpp:6:11]: (style) The comparison 'i == a.x' is always true because 'i' and 'a.x' represent the same value. [knownConditionTrueFalse]\n",
8942
+
"[test.cpp:4:9] -> [test.cpp:3:9]: (style, inconclusive) Same expression used in consecutive assignments of 'i' and 'j'. [duplicateAssignExpression]\n",
8915
8943
errout_str());
8916
8944
8917
8945
check("struct A { int x; int y; };"
@@ -8923,8 +8951,7 @@ class TestOther : public TestFixture {
8923
8951
" if (j == a.x) {}\n"
8924
8952
"}");
8925
8953
ASSERT_EQUALS(
8926
-
"[test.cpp:4:9] -> [test.cpp:3:9]: (style, inconclusive) Same expression used in consecutive assignments of 'i' and 'j'. [duplicateAssignExpression]\n"
8927
-
"[test.cpp:4:14] -> [test.cpp:6:11]: (style) The comparison 'j == a.x' is always true because 'j' and 'a.x' represent the same value. [knownConditionTrueFalse]\n",
8954
+
"[test.cpp:4:9] -> [test.cpp:3:9]: (style, inconclusive) Same expression used in consecutive assignments of 'i' and 'j'. [duplicateAssignExpression]\n",
8928
8955
errout_str());
8929
8956
8930
8957
// Issue #8612
@@ -9992,9 +10019,7 @@ class TestOther : public TestFixture {
9992
10019
" u.g();\n"
9993
10020
" if (c == m->get()) {}\n"
9994
10021
"}\n");
9995
-
TODO_ASSERT_EQUALS("",
9996
-
"[test.cpp:16:33] -> [test.cpp:18:11]: (style) The comparison 'c == m->get()' is always true because 'c' and 'm->get()' represent the same value. [knownConditionTrueFalse]\n",
0 commit comments