* Add test for #10603

* Add test for #10559

* Add test for #10212

* Format

* Add test for #9744

* Format

* Add test for #11140
This commit is contained in:
chrchr-github 2022-08-18 23:37:41 +02:00 committed by GitHub
parent e09f5f0db7
commit 2fee7a6e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -3585,6 +3585,19 @@ private:
" f(\"bbb\", 3);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(int i, const char* a) {\n" // #11140
" (void)a[i];\n"
"}\n"
"void g() {\n"
" for (int i = 0; \"01234\"[i]; ++i)\n"
" f(i, \"56789\");\n"
"}\n"
"void h() {\n"
" for (int i = 0; \"012\"[i]; ++i)\n"
" f(i, \"345\");\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

View File

@ -5964,6 +5964,15 @@ private:
" }\n"
"}");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:5]: (style) The comparison 'Diag == 0' is always true.\n", errout.str());
// #9744
check("void f(const std::vector<int>& ints) {\n"
" int i = 0;\n"
" for (int p = 0; i < ints.size(); ++i) {\n"
" if (p == 0) {}\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) The comparison 'p == 0' is always true.\n", errout.str());
}
void duplicateExpression8() {