Fix 10916: FP: uninitvar (#3949)

This commit is contained in:
Paul Fultz II 2022-03-27 03:01:58 -05:00 committed by GitHub
parent 63d96e49fc
commit 21b8c36eb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -7076,7 +7076,7 @@ static void valueFlowUninit(TokenList* tokenlist, SymbolDatabase* /*symbolDataba
uninitValue.valueType = ValueFlow::Value::ValueType::UNINIT;
uninitValue.tokvalue = tok;
if (var->isArray())
uninitValue.indirect = 1;
uninitValue.indirect = var->dimensions().size();
bool partial = false;

View File

@ -6139,6 +6139,19 @@ private:
" (*fp[0])();\n"
"}");
ASSERT_EQUALS("", errout.str());
valueFlowUninit("static void Foo(double* p) {\n"
" p[0] = 0;\n"
" p[1] = 0;\n"
" p[2] = 0;\n"
" p[3] = 0;\n"
"}\n"
"double f() {\n"
" double L[2][2];\n"
" Foo(*L);\n"
" return L[0][0];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void uninitvar_memberaccess() {