* Add test for #10607

* Format
This commit is contained in:
chrchr-github 2021-11-24 14:42:19 +01:00 committed by GitHub
parent 6a822f4c06
commit a6b8339990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -165,6 +165,7 @@ private:
TEST_CASE(checkSuspiciousSemicolon1);
TEST_CASE(checkSuspiciousSemicolon2);
TEST_CASE(checkSuspiciousSemicolon3);
TEST_CASE(checkSuspiciousComparison);
TEST_CASE(checkInvalidFree);
@ -6698,6 +6699,19 @@ private:
ASSERT_EQUALS("", errout.str());
}
void checkSuspiciousComparison() {
checkP("void f(int a, int b) {\n"
" a > b;\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Found suspicious operator '>'\n", errout.str());
checkP("void f() {\n" // #10607
" for (auto p : m)\n"
" std::vector<std::pair<std::string, std::string>> k;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void checkInvalidFree() {
check("void foo(char *p) {\n"
" char *a; a = malloc(1024);\n"