File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4350,6 +4350,28 @@ class TestUninitVar : public TestFixture {
43504350 " f(i);\n "
43514351 " }" );
43524352 ASSERT_EQUALS (" " , errout_str ());
4353+
4354+ valueFlowUninit (" int f(int& i, int j, int k) {\n " // #12514
4355+ " if (k)\n "
4356+ " i = 2;\n "
4357+ " return i + j;\n "
4358+ " }\n "
4359+ " int main() {\n "
4360+ " int i;\n "
4361+ " return f(i, 1, 0);\n "
4362+ " }" );
4363+ ASSERT_EQUALS (" [test.cpp:8] -> [test.cpp:4]: (warning) Uninitialized variable: i\n " , errout_str ());
4364+
4365+ valueFlowUninit (" int f(int& i, int k) {\n "
4366+ " if (k)\n "
4367+ " i = 2;\n "
4368+ " return i;\n "
4369+ " }\n "
4370+ " int main() {\n "
4371+ " int i;\n "
4372+ " return f(i, 0);\n "
4373+ " }" );
4374+ ASSERT_EQUALS (" [test.cpp:8] -> [test.cpp:4]: (warning) Uninitialized variable: i\n " , errout_str ());
43534375 }
43544376
43554377 void uninitStructMember () { // struct members
You can’t perform that action at this time.
0 commit comments