diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 10eedda9b..0a87ba0ab 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -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; } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 5d4b6ad79..1cc77a657 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -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() {