diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 77aec7a5a..ca62cec7d 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -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"