This commit is contained in:
chrchr-github 2022-01-06 15:21:05 +01:00 committed by GitHub
parent 6c55f9cf88
commit 9fda86eb6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -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))

View File

@ -93,6 +93,7 @@ private:
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
@ -633,6 +634,16 @@ private:
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() {