Fix #11305 FP uninitvar with unseen typedef (#4612)

This commit is contained in:
chrchr-github 2022-12-07 09:14:22 +01:00 committed by GitHub
parent 0e57c27dd3
commit 89dba226dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -2970,7 +2970,7 @@ ExprUsage getExprUsage(const Token* tok, int indirect, const Settings* settings)
if (Token::simpleMatch(tok->astParent(), "=") && astIsRHS(tok))
return ExprUsage::Used;
// Function call or index
if (Token::Match(tok->astParent(), "(|[") && !tok->astParent()->isCast() &&
if (((Token::simpleMatch(tok->astParent(), "(") && !tok->astParent()->isCast()) || (Token::simpleMatch(tok->astParent(), "[") && tok->valueType())) &&
(astIsLHS(tok) || Token::simpleMatch(tok->astParent(), "( )")))
return ExprUsage::Used;
}

View File

@ -6363,6 +6363,12 @@ private:
" return L[0][0];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
valueFlowUninit("void f() {\n" // #11305
" type_t a;\n"
" a[0] = 0;\n"
"}\n", "test.c");
ASSERT_EQUALS("", errout.str());
}
void uninitvar_memberaccess() {