From cc74c8e1dab81c5a9466e6ed21e3eb65fa18d56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 21 May 2021 10:42:58 +0200 Subject: [PATCH] Uninitialized variables; Moved test case. ValueFlow can detect issue. --- test/testuninitvar.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 15579d68d..e08439fbb 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -1918,19 +1918,6 @@ private: "}"); ASSERT_EQUALS("", errout.str()); - checkUninitVar("struct StgStrm {\n" - " StgIo& rIo;\n" - " StgStrm(StgIo&);\n" - " virtual sal_Int32 Write();\n" - "};\n" - "void Tmp2Strm() {\n" - " StgStrm* pNewStrm;\n" - " if (someflag)\n" - " pNewStrm = new StgStrm(rIo);\n" - " pNewStrm->Write();\n" - "}"); - // TODO ASSERT_EQUALS("[test.cpp:10]: (error) Uninitialized variable: pNewStrm\n", errout.str()); - // #6450 - calling a member function is allowed if memory was allocated by new checkUninitVar("struct EMFPFont {\n" " bool family;\n" @@ -4400,6 +4387,19 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + valueFlowUninit("struct S {\n" + " S& rIo;\n" + " S(S&);\n" + " void Write();\n" + "};\n" + "void foo(bool b) {\n" + " S* p;\n" + " if (b)\n" + " p = new S;\n" + " p->Write();\n" + "}"); + ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:10]: (error) Uninitialized variable: p\n", errout.str()); + // Unknown types { valueFlowUninit("void a()\n"