* Fix #11459 uninitvar false positive * Format
This commit is contained in:
parent
9ea223b367
commit
023e79b6c2
|
@ -4959,6 +4959,11 @@ const Enumerator * SymbolDatabase::findEnumerator(const Token * tok, std::set<st
|
|||
if (varTok && varTok->variable() && varTok->variable()->type() && varTok->variable()->type()->classScope)
|
||||
scope = varTok->variable()->type()->classScope;
|
||||
}
|
||||
else if (Token::simpleMatch(tok->astParent(), "[")) {
|
||||
const Token* varTok = tok->astParent()->previous();
|
||||
if (varTok && varTok->variable() && varTok->variable()->scope() && Token::simpleMatch(tok->astParent()->astOperand1(), "::"))
|
||||
scope = varTok->variable()->scope();
|
||||
}
|
||||
|
||||
for (std::vector<Scope *>::const_iterator s = scope->nestedList.cbegin(); s != scope->nestedList.cend(); ++s) {
|
||||
enumerator = (*s)->findEnumerator(tokStr);
|
||||
|
|
|
@ -5998,6 +5998,21 @@ private:
|
|||
" if ((cp = getenv(envar)) != NULL) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #11459
|
||||
valueFlowUninit("struct S {\n"
|
||||
" enum E { N = 3 };\n"
|
||||
" static const int A[N];\n"
|
||||
" static void f();\n"
|
||||
"};\n"
|
||||
"const int S::A[N] = { 0, 1, 2 };\n"
|
||||
"void S::f() {\n"
|
||||
" int tmp[N];\n"
|
||||
" for (int i = 0; i < N; i++)\n"
|
||||
" tmp[i] = 0;\n"
|
||||
" if (tmp[0]) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
|
||||
|
|
Loading…
Reference in New Issue