parent
544ec38ca9
commit
6c24d2b865
|
@ -7424,6 +7424,8 @@ static bool needsInitialization(const Variable* var, bool cpp)
|
||||||
{
|
{
|
||||||
if (!var)
|
if (!var)
|
||||||
return false;
|
return false;
|
||||||
|
if (var->hasDefault())
|
||||||
|
return false;
|
||||||
if (var->isPointer())
|
if (var->isPointer())
|
||||||
return true;
|
return true;
|
||||||
if (var->type() && var->type()->isUnionType())
|
if (var->type() && var->type()->isUnionType())
|
||||||
|
|
|
@ -6127,7 +6127,7 @@ private:
|
||||||
" int a = ab.a;\n"
|
" int a = ab.a;\n"
|
||||||
" int b = ab.b;\n"
|
" int b = ab.b;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: ab.a\n", errout.str());
|
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: ab.b\n", "", errout.str());
|
||||||
|
|
||||||
// STL class member
|
// STL class member
|
||||||
valueFlowUninit("struct A {\n"
|
valueFlowUninit("struct A {\n"
|
||||||
|
@ -6227,6 +6227,17 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: s\n",
|
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: s\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
|
|
||||||
|
valueFlowUninit("struct S {\n" // #11321
|
||||||
|
" int a = 0;\n"
|
||||||
|
" int b;\n"
|
||||||
|
"};\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" S s1;\n"
|
||||||
|
" s1.b = 1;\n"
|
||||||
|
" S s2 = s1;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitvar_memberfunction() {
|
void uninitvar_memberfunction() {
|
||||||
|
|
Loading…
Reference in New Issue