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
const std::string& op = opTok ? opTok->str() : "&&";
2463
-
std::string msg = "Same expression on both sides of \'" + op + "\'";
2467
+
std::string msg = "Same expression " + (hasMultipleExpr ? "\'" + expr1 + "\'" + " found multiple times in chain of \'" + op + "\' operators" : "on both sides of \'" + op + "\'");
2464
2468
constchar *id = "duplicateExpression";
2465
2469
if (expr1 != expr2 && (!opTok || !opTok->isArithmeticalOp())) {
Copy file name to clipboardExpand all lines: test/testautovariables.cpp
+1-3Lines changed: 1 addition & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3382,15 +3382,13 @@ class TestAutoVariables : public TestFixture {
3382
3382
"[test.cpp:3] -> [test.cpp:3] -> [test.cpp:2] -> [test.cpp:4]: (error) Returning object that points to local variable 'i' that will be invalid when returning.\n",
3383
3383
errout.str());
3384
3384
3385
-
// TODO: Ast is missing for this case
3386
3385
check("std::vector<int*> f() {\n"
3387
3386
" int i = 0;\n"
3388
3387
" std::vector<int*> v{&i, &i};\n"
3389
3388
" return v;\n"
3390
3389
"}");
3391
-
TODO_ASSERT_EQUALS(
3390
+
ASSERT_EQUALS(
3392
3391
"[test.cpp:3] -> [test.cpp:3] -> [test.cpp:2] -> [test.cpp:4]: (error) Returning object that points to local variable 'i' that will be invalid when returning.\n",
Copy file name to clipboardExpand all lines: test/testother.cpp
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -160,6 +160,7 @@ class TestOther : public TestFixture {
160
160
TEST_CASE(duplicateExpression13); // #7899
161
161
TEST_CASE(duplicateExpression14); // #9871
162
162
TEST_CASE(duplicateExpression15); // #10650
163
+
TEST_CASE(duplicateExpression16); // #10569
163
164
TEST_CASE(duplicateExpressionLoop);
164
165
TEST_CASE(duplicateValueTernary);
165
166
TEST_CASE(duplicateExpressionTernary); // #6391
@@ -5125,7 +5126,7 @@ class TestOther : public TestFixture {
5125
5126
check("void foo() {\n"
5126
5127
" if (x!=2 || y!=3 || x!=2) {}\n"
5127
5128
"}");
5128
-
ASSERT_EQUALS("[test.cpp:2]: (style) Same expression on both sides of '||'.\n", errout.str());
5129
+
ASSERT_EQUALS("[test.cpp:2]: (style) Same expression 'x!=2' found multiple times in chain of '||' operators.\n", errout.str());
5129
5130
5130
5131
check("void foo() {\n"
5131
5132
" if (x!=2 && (x=y) && x!=2) {}\n"
@@ -5601,7 +5602,8 @@ class TestOther : public TestFixture {
5601
5602
" const bool c = a;\n"
5602
5603
" return a && b && c;\n"
5603
5604
"}");
5604
-
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Same expression on both sides of '&&' because 'a' and 'c' represent the same value.\n", errout.str());
5605
+
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Same expression 'a' found multiple times in chain of '&&' operators because 'a' and 'c' represent the same value.\n",
5606
+
errout.str());
5605
5607
5606
5608
// 6906
5607
5609
check("void f(const bool b) {\n"
@@ -5785,6 +5787,31 @@ class TestOther : public TestFixture {
5785
5787
errout.str());
5786
5788
}
5787
5789
5790
+
voidduplicateExpression16() { //#10569
5791
+
check("void f(const std::string& a) {\n"
5792
+
" if ((a == \"x\") ||\n"
5793
+
" (a == \"42\") ||\n"
5794
+
" (a == \"y\") ||\n"
5795
+
" (a == \"42\")) {}\n"
5796
+
"}\n"
5797
+
"void g(const std::string& a) {\n"
5798
+
" if ((a == \"42\") ||\n"
5799
+
" (a == \"x\") ||\n"
5800
+
" (a == \"42\") ||\n"
5801
+
" (a == \"y\")) {}\n"
5802
+
"}\n"
5803
+
"void h(const std::string& a) {\n"
5804
+
" if ((a == \"42\") ||\n"
5805
+
" (a == \"x\") ||\n"
5806
+
" (a == \"y\") ||\n"
5807
+
" (a == \"42\")) {}\n"
5808
+
"}\n");
5809
+
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:4]: (style) Same expression 'a==\"42\"' found multiple times in chain of '||' operators.\n"
5810
+
"[test.cpp:7] -> [test.cpp:9]: (style) Same expression 'a==\"42\"' found multiple times in chain of '||' operators.\n"
5811
+
"[test.cpp:13] -> [test.cpp:16]: (style) Same expression 'a==\"42\"' found multiple times in chain of '||' operators.\n",
0 commit comments