From 203d3e916bffb6bf365872a767e22758dc79b724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 14 Nov 2013 16:10:00 +0100 Subject: [PATCH] Fixed #5173 (false positive Variable XX is reassigned a value before the old one has been used) --- lib/checkother.cpp | 7 +++++-- test/testother.cpp | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 431c51e21..c81af18cf 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -626,9 +626,12 @@ static void eraseMemberAssignments(const unsigned int varId, std::map >::const_iterator it = membervars.find(varId); if (it != membervars.end()) { - const std::set &v = it->second; - for (std::set::const_iterator vit = v.begin(); vit != v.end(); ++vit) + const std::set v = it->second; + for (std::set::const_iterator vit = v.begin(); vit != v.end(); ++vit) { varAssignments.erase(*vit); + if (*vit != varId) + eraseMemberAssignments(*vit, membervars, varAssignments); + } } } diff --git a/test/testother.cpp b/test/testother.cpp index d6491de8d..8ab7516f4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6417,6 +6417,13 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("void f(struct AB *ab) {\n" // # + " ab->data->x = 1;\n" + " ab = &ab1;\n" + " ab->data->x = 2;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + // don't crash check("struct data {\n" " struct { int i; } fc;\n"