diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 31960cdc8..67897b465 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1347,6 +1347,8 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok, return true; else if (Token::Match(tok->previous(), "[(,] %var% [,)]") && isVariableUsage(scope, tok, var.isPointer())) uninitvarError(tok, tok->str() + "." + membervar->name()); + else + return true; } else { // Use variable if (!suppressErrors && isVariableUsage(scope, tok, var.isPointer())) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index c639fd914..149688b1c 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2572,6 +2572,15 @@ private: " do_something(ab);\n" "}\n", "test.c", true); ASSERT_EQUALS("", errout.str()); + + checkUninitVar2("struct AB { int a; int b; };\n" + "void do_something(const struct AB ab);\n" + "void f(void) {\n" + " struct AB ab;\n" + " ab = getAB();\n" + " do_something(ab);\n" + "}\n", "test.c", true); + ASSERT_EQUALS("", errout.str()); } };