File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,6 +211,7 @@ class TestLeakAutoVar : public TestFixture {
211211 TEST_CASE (inlineFunction); // #3989
212212
213213 TEST_CASE (smartPtrInContainer); // #8262
214+ TEST_CASE (unconditionalScope);
214215
215216 TEST_CASE (functionCallCastConfig); // #9652
216217 TEST_CASE (functionCallLeakIgnoreConfig); // #7923
@@ -3178,6 +3179,24 @@ class TestLeakAutoVar : public TestFixture {
31783179 ASSERT_EQUALS (" " , errout_str ());
31793180 }
31803181
3182+ void unconditionalScope () { // #14945
3183+ check (" void f() {\n "
3184+ " {\n "
3185+ " int* p = new int;\n "
3186+ " *p = 1;\n "
3187+ " }\n "
3188+ " {\n "
3189+ " int* q = new int;\n "
3190+ " *q = 2;\n "
3191+ " delete q;\n "
3192+ " }\n "
3193+ " int* r = new int;\n "
3194+ " *r = 3;\n "
3195+ " delete r;\n "
3196+ " }\n " , dinit (CheckOptions, $.cpp = true ));
3197+ ASSERT_EQUALS (" [test.cpp:5:5]: (error) Memory leak: p [memleak]\n " , errout_str ());
3198+ }
3199+
31813200 void functionCallCastConfig () { // #9652
31823201 constexpr char xmldata[] = " <?xml version=\" 1.0\" ?>\n "
31833202 " <def format=\" 2\" >\n "
You can’t perform that action at this time.
0 commit comments