diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 612697562..b89b91d97 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -67,6 +67,7 @@ private: TEST_CASE(uninitvar_unconditionalTry); TEST_CASE(uninitvar_funcptr); // #6404 TEST_CASE(uninitvar_operator); // #6680 + TEST_CASE(uninitvar_ternaryexpression); // #4683 TEST_CASE(syntax_error); // Ticket #5073 @@ -3767,6 +3768,20 @@ private: ASSERT_EQUALS("", errout.str()); } + void uninitvar_ternaryexpression() { // #4683 + checkUninitVar("struct B { int asd; };\n" + "int f() {\n" + " int a=0;\n" + " struct B *b;\n" + " if (x) {\n" + " a = 1;\n" + " b = p;\n" + " }\n" + " return a ? b->asd : 0;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } + void syntax_error() { // Ticket #5073 // Nominal mode => No output checkUninitVar("struct flex_array {};\n"