File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -244,11 +244,19 @@ void CheckClass::constructors()
244244 if (!var.isPointer () && !var.isPointerArray () && var.isClass () && func.type == FunctionType::eConstructor) {
245245 // Unknown type so assume it is initialized
246246 if (!var.type ()) {
247- if (var.isStlType () && var.valueType () && var.valueType ()->containerTypeToken && var.getTypeName () == " std::array" ) {
248- const Token* ctt = var.valueType ()->containerTypeToken ;
249- if (!ctt->isStandardType () &&
250- (!ctt->type () || ctt->type ()->needInitialization != Type::NeedInitialization::True) &&
251- !mSettings ->library .podtype (ctt->str ())) // TODO: handle complex type expression
247+ if (var.isStlType () && var.valueType () && var.valueType ()->containerTypeToken ) {
248+ if (var.valueType ()->type == ValueType::Type::ITERATOR)
249+ {
250+ // needs initialization
251+ }
252+ else if (var.getTypeName () == " std::array" ) {
253+ const Token* ctt = var.valueType ()->containerTypeToken ;
254+ if (!ctt->isStandardType () &&
255+ (!ctt->type () || ctt->type ()->needInitialization != Type::NeedInitialization::True) &&
256+ !mSettings ->library .podtype (ctt->str ())) // TODO: handle complex type expression
257+ continue ;
258+ }
259+ else
252260 continue ;
253261 }
254262 else
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ class TestConstructors : public TestFixture {
173173 TEST_CASE (uninitVar34); // ticket #10841
174174 TEST_CASE (uninitVar35);
175175 TEST_CASE (uninitVar36);
176+ TEST_CASE (uninitVar37);
176177 TEST_CASE (uninitVarEnum1);
177178 TEST_CASE (uninitVarEnum2); // ticket #8146
178179 TEST_CASE (uninitVarStream);
@@ -3031,6 +3032,15 @@ class TestConstructors : public TestFixture {
30313032 ASSERT_EQUALS (" [test.cpp:5:5]: (warning) Member variable 'S::b' is not initialized in the constructor. [uninitMemberVar]\n " , errout_str ());
30323033 }
30333034
3035+ void uninitVar37 () {
3036+ const Settings s = settingsBuilder (settings).library (" std.cfg" ).build ();
3037+ check (" struct C {\n " // #13989
3038+ " C() = default;\n "
3039+ " std::list<int>::const_iterator it;\n "
3040+ " };\n " , dinit (CheckOptions, $.s = &s));
3041+ ASSERT_EQUALS (" [test.cpp:2:5]: (warning) Member variable 'C::it' is not initialized in the constructor. [uninitMemberVar]\n " , errout_str ());
3042+ }
3043+
30343044 void uninitVarArray1 () {
30353045 check (" class John\n "
30363046 " {\n "
You can’t perform that action at this time.
0 commit comments