diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index e30dfebc14b..887e38b61b8 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1579,7 +1579,7 @@ static bool isLeafDot(const Token* tok) const Token * parent = tok->astParent(); if (!Token::simpleMatch(parent, ".")) return false; - if (parent->astOperand2() == tok) + if (parent->astOperand2() == tok && !Token::simpleMatch(parent->astParent(), ".")) return true; return isLeafDot(parent); } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 13879f7b22f..40962370175 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -6139,6 +6139,27 @@ class TestUninitVar : public TestFixture { " int& r = *p;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + valueFlowUninit("void f(std::stringstream& ss) {\n" // #11805 + " int x;\n" + " int* p = &x;\n" + " ss >> *p;\n" + "}\n" + "void g() {\n" + " int x;\n" + " int* p = &x;\n" + " int& r = *p;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + valueFlowUninit("struct S1 { char a[10]; };\n" // #11804 + "struct S2 { struct S1 s1; };\n" + "void init(char* c);\n" + "void f() {\n" + " struct S2 s2;\n" + " init(s2.s1.a);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value