Add test for #5473 (#3831)

This commit is contained in:
chrchr-github 2022-02-15 12:52:10 +01:00 committed by GitHub
parent d131235a53
commit a5674182bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -160,6 +160,7 @@ private:
TEST_CASE(ifelse20); // #10182
TEST_CASE(ifelse21);
TEST_CASE(ifelse22); // #10187
TEST_CASE(ifelse23); // #5473
// switch
TEST_CASE(switch1);
@ -1709,6 +1710,13 @@ private:
ASSERT_EQUALS("", errout.str());
}
void ifelse23() { // #5473
check("void f() {\n"
" if (FILE* fp = fopen(\"x\", \"r\")) {}\n"
"}\n");
ASSERT_EQUALS("[test.c:2]: (error) Resource leak: fp\n", errout.str());
}
void switch1() {
check("void f() {\n"
" char *p = 0;\n"