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()
244
244
if (!var.isPointer () && !var.isPointerArray () && var.isClass () && func.type == FunctionType::eConstructor) {
245
245
// Unknown type so assume it is initialized
246
246
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
252
260
continue ;
253
261
}
254
262
else
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ class TestConstructors : public TestFixture {
173
173
TEST_CASE (uninitVar34); // ticket #10841
174
174
TEST_CASE (uninitVar35);
175
175
TEST_CASE (uninitVar36);
176
+ TEST_CASE (uninitVar37);
176
177
TEST_CASE (uninitVarEnum1);
177
178
TEST_CASE (uninitVarEnum2); // ticket #8146
178
179
TEST_CASE (uninitVarStream);
@@ -3031,6 +3032,15 @@ class TestConstructors : public TestFixture {
3031
3032
ASSERT_EQUALS (" [test.cpp:5:5]: (warning) Member variable 'S::b' is not initialized in the constructor. [uninitMemberVar]\n " , errout_str ());
3032
3033
}
3033
3034
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
+
3034
3044
void uninitVarArray1 () {
3035
3045
check (" class John\n "
3036
3046
" {\n "
You can’t perform that action at this time.
0 commit comments