Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
if (var.isClass()) {
if (var.type()) {
// does this type need initialization?
if (var.type()->needInitialization == Type::NeedInitialization::True)
if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault())
needInitialization = true;
else if (var.type()->needInitialization == Type::NeedInitialization::Unknown) {
if (!(var.valueType() && var.valueType()->type == ValueType::CONTAINER))
Expand Down
11 changes: 11 additions & 0 deletions test/testconstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class TestConstructors : public TestFixture {
TEST_CASE(noConstructor10); // ticket #6614
TEST_CASE(noConstructor11); // ticket #3552
TEST_CASE(noConstructor12); // #8951 - member initialization
TEST_CASE(noConstructor13); // #9998

TEST_CASE(forwardDeclaration); // ticket #4290/#3190

Expand Down Expand Up @@ -633,6 +634,16 @@ class TestConstructors : public TestFixture {
ASSERT_EQUALS("", errout.str());
}

void noConstructor13() { // #9998
check("struct C { int v; };\n"
"struct B { C c[5] = {}; };\n"
"struct A {\n"
" A() {}\n"
" B b;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}

// ticket #4290 "False Positive: style (noConstructor): The class 'foo' does not have a constructor."
// ticket #3190 "SymbolDatabase: Parse of sub class constructor fails"
void forwardDeclaration() {
Expand Down