File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -937,6 +937,8 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
937937 bool unknown = false ;
938938
939939 for (const Variable& var: scope.varlist ) {
940+ if (var.isStatic ())
941+ continue ;
940942 if (var.isClass () && !var.isReference ()) {
941943 if (var.type ()) {
942944 // does this type need initialization?
@@ -947,7 +949,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
947949 unknown = true ;
948950 }
949951 }
950- } else if (!var.hasDefault () && !var. isStatic () ) {
952+ } else if (!var.hasDefault ()) {
951953 needInitialization = true ;
952954 break ;
953955 }
Original file line number Diff line number Diff line change @@ -3034,6 +3034,14 @@ class TestSymbolDatabase : public TestFixture {
30343034 " };\n " );
30353035 ASSERT_EQUALS (" " , errout.str ());
30363036 }
3037+ {
3038+ GET_SYMBOL_DB_DBG (" struct S {\n " // #12395
3039+ " static S s;\n "
3040+ " };\n " );
3041+ ASSERT_EQUALS (" " , errout.str ());
3042+ const Variable* const s = db->getVariableFromVarId (1 );
3043+ ASSERT (s->scope ()->definedType ->needInitialization == Type::NeedInitialization::False);
3044+ }
30373045 }
30383046
30393047 void tryCatch1 () {
You can’t perform that action at this time.
0 commit comments