File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -2948,7 +2948,9 @@ void CheckOther::checkDuplicateExpression()
29482948 while (parent && parent->astParent ()) {
29492949 parent = parent->astParent ();
29502950 }
2951- if (parent && parent->previous () && isStaticAssert (*mSettings , parent->previous ())) {
2951+ if (parent && parent->previous () &&
2952+ (isStaticAssert (*mSettings , parent->previous ()) ||
2953+ Token::simpleMatch (parent->previous (), " assert" ))) {
29522954 continue ;
29532955 }
29542956 }
Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ class TestOther : public TestFixture {
195195 TEST_CASE(duplicateExpression16); // #10569
196196 TEST_CASE(duplicateExpression17); // #12036
197197 TEST_CASE(duplicateExpression18);
198+ TEST_CASE(duplicateExpression19);
198199 TEST_CASE(duplicateExpressionLoop);
199200 TEST_CASE(duplicateValueTernary);
200201 TEST_CASE(duplicateValueTernarySizeof); // #13773
@@ -7988,6 +7989,14 @@ class TestOther : public TestFixture {
79887989 ASSERT_EQUALS("", errout_str());
79897990 }
79907991
7992+ void duplicateExpression19() {
7993+ checkP("const int i = 0;\n"
7994+ "void f() {\n"
7995+ " assert(i == 0);\n"
7996+ "}\n");
7997+ ASSERT_EQUALS("", errout_str());
7998+ }
7999+
79918000 void duplicateExpressionLoop() {
79928001 check("void f() {\n"
79938002 " int a = 1;\n"
You can’t perform that action at this time.
0 commit comments