File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,13 +174,13 @@ void CheckClass::constructors()
174174
175175 // #3196 => bailout if there are nested unions
176176 // TODO: handle union variables better
177- {
178- const bool bailout = std::any_of (scope->nestedList .cbegin (), scope->nestedList .cend (), [](const Scope* nestedScope) {
179- return nestedScope->type == ScopeType::eUnion;
180- });
181- if (bailout)
182- continue ;
183- }
177+ // {
178+ // const bool bailout = std::any_of(scope->nestedList.cbegin(), scope->nestedList.cend(), [](const Scope* nestedScope) {
179+ // return nestedScope->type == ScopeType::eUnion;
180+ // });
181+ // if (bailout)
182+ // continue;
183+ // }
184184
185185
186186 std::vector<Usage> usageList = createUsageList (scope);
@@ -311,7 +311,7 @@ void CheckClass::constructors()
311311 if (!precedes (scope->bodyStart , func.tokenDef ))
312312 continue ;
313313 const Scope *varType = var.typeScope ();
314- if (!varType || varType-> type != ScopeType::eUnion) {
314+ {
315315 const bool derived = scope != var.scope ();
316316 if (func.type == FunctionType::eConstructor &&
317317 func.nestedIn && (func.nestedIn ->numConstructors - func.nestedIn ->numCopyOrMoveConstructors ) > 1 &&
Original file line number Diff line number Diff line change @@ -1302,7 +1302,7 @@ class TestConstructors : public TestFixture {
13021302 " {\n "
13031303 " }\n "
13041304 " };" );
1305- TODO_ASSERT_EQUALS (" [test.cpp:9]: (warning) Member variable 'Fred::U' is not initialized in the constructor.\n " , " " , errout_str ());
1305+ ASSERT_EQUALS (" [test.cpp:9]: (warning) Member variable 'Fred::U' is not initialized in the constructor.\n " , errout_str ());
13061306 }
13071307
13081308
@@ -3428,9 +3428,6 @@ class TestConstructors : public TestFixture {
34283428 }
34293429
34303430 void uninitVarUnion2 () {
3431- // If the "data_type" is 0 it means union member "data" is invalid.
3432- // So it's ok to not initialize "data".
3433- // related forum: http://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&p=1806
34343431 check (" union Data { int id; int *ptr; };\n "
34353432 " \n "
34363433 " class Fred {\n "
@@ -3441,7 +3438,7 @@ class TestConstructors : public TestFixture {
34413438 " Fred() : data_type(0)\n "
34423439 " { }\n "
34433440 " };" );
3444- ASSERT_EQUALS (" " , errout_str ());
3441+ ASSERT_EQUALS (" [test.cpp:8]: (warning) Member variable 'Fred::data' is not initialized in the constructor. \n " , errout_str ());
34453442 }
34463443
34473444 void uninitMissingFuncDef () {
You can’t perform that action at this time.
0 commit comments