#10026: Added a regression test for 'false negative: duplicateExpression'

This commit is contained in:
orbitcowboy 2021-05-24 08:54:45 +02:00
parent ab50a75d8a
commit df6b0bcd87
1 changed files with 10 additions and 0 deletions

View File

@ -146,6 +146,7 @@ private:
TEST_CASE(duplicateExpression9); // #9320
TEST_CASE(duplicateExpression10); // #9485
TEST_CASE(duplicateExpression11); // #8916 (function call)
TEST_CASE(duplicateExpression12); // #10026
TEST_CASE(duplicateExpressionLoop);
TEST_CASE(duplicateValueTernary);
TEST_CASE(duplicateExpressionTernary); // #6391
@ -5240,6 +5241,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void duplicateExpression12() { //#10026
check("int f(const std::vector<int> &buffer, const uint8_t index)\n"
"{\n"
" int var = buffer[index - 1];\n"
" return buffer[index - 1] - var;\n" // <<
"}");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Same expression on both sides of '-'.\n", errout.str());
}
void duplicateExpressionLoop() {
check("void f() {\n"
" int a = 1;\n"