| 233 | } |
| 234 | |
| 235 | void CheckUninitVarImpl::checkStruct(const Token *tok, const Variable &structvar) |
| 236 | { |
| 237 | const Token *typeToken = structvar.typeStartToken(); |
| 238 | while (Token::Match(typeToken, "%name% ::")) |
| 239 | typeToken = typeToken->tokAt(2); |
| 240 | const SymbolDatabase * symbolDatabase = mTokenizer->getSymbolDatabase(); |
| 241 | for (const Scope *scope2 : symbolDatabase->classAndStructScopes) { |
| 242 | if (scope2->className == typeToken->str() && scope2->numConstructors == 0U) { |
| 243 | for (const Variable &var : scope2->varlist) { |
| 244 | if (var.isStatic() || var.hasDefault() || var.isArray() || |
| 245 | (!mTokenizer->isC() && var.isClass() && (!var.type() || var.type()->needInitialization != Type::NeedInitialization::True))) |
| 246 | continue; |
| 247 | |
| 248 | // is the variable declared in a inner union? |
| 249 | bool innerunion = false; |
| 250 | for (const Scope *innerScope : scope2->nestedList) { |
| 251 | if (innerScope->type == ScopeType::eUnion) { |
| 252 | if (var.typeStartToken()->linenr() >= innerScope->bodyStart->linenr() && |
| 253 | var.typeStartToken()->linenr() <= innerScope->bodyEnd->linenr()) { |
| 254 | innerunion = true; |
| 255 | break; |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | if (!innerunion) { |
| 261 | Alloc alloc = NO_ALLOC; |
| 262 | const Token *tok2 = tok; |
| 263 | if (tok->str() == "}") |
| 264 | tok2 = tok2->next(); |
| 265 | std::map<nonneg int, VariableValue> variableValue = getVariableValues(structvar.typeStartToken()); |
| 266 | checkScopeForVariable(tok2, structvar, nullptr, nullptr, &alloc, var.name(), variableValue); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | static VariableValue operator!(VariableValue v) |
| 274 | { |