Fix 10681: FP ctuuninitvar with array member (#3686)
This commit is contained in:
parent
635c09643d
commit
0c9eb5d190
|
@ -6786,6 +6786,9 @@ static void valueFlowUninit(TokenList* tokenlist, SymbolDatabase* /*symbolDataba
|
||||||
for (const Variable& memVar : scope->varlist) {
|
for (const Variable& memVar : scope->varlist) {
|
||||||
if (!memVar.isPublic())
|
if (!memVar.isPublic())
|
||||||
continue;
|
continue;
|
||||||
|
// Skip array since we cant track partial initialization from nested subexpressions
|
||||||
|
if (memVar.isArray())
|
||||||
|
continue;
|
||||||
if (!needsInitialization(&memVar, tokenlist->isCPP())) {
|
if (!needsInitialization(&memVar, tokenlist->isCPP())) {
|
||||||
partial = true;
|
partial = true;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -5921,6 +5921,35 @@ private:
|
||||||
" x = a.m;\n"
|
" x = a.m;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
valueFlowUninit("struct S {\n"
|
||||||
|
" int t[1];\n"
|
||||||
|
"};\n"
|
||||||
|
"int f(const S* ps) {\n"
|
||||||
|
" return ps->t[0];\n"
|
||||||
|
"}\n"
|
||||||
|
"void g() {\n"
|
||||||
|
" S s;\n"
|
||||||
|
" s.t[0] = 1;\n"
|
||||||
|
" f(&s);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
valueFlowUninit("struct X {\n"
|
||||||
|
" int a, b;\n"
|
||||||
|
"};\n"
|
||||||
|
"struct S {\n"
|
||||||
|
" X t;\n"
|
||||||
|
"};\n"
|
||||||
|
"int f(const S* ps) {\n"
|
||||||
|
" return ps->t.a;\n"
|
||||||
|
"}\n"
|
||||||
|
"void g() {\n"
|
||||||
|
" S s;\n"
|
||||||
|
" s.t.a = 1;\n"
|
||||||
|
" f(&s);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitvar_memberfunction() {
|
void uninitvar_memberfunction() {
|
||||||
|
|
Loading…
Reference in New Issue