From 350908d0e9615a50e986b442f688614908db7e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 31 Dec 2015 15:30:33 +0100 Subject: [PATCH] Fix FP in CheckUnusedVar. Caused by #7230 fix. --- lib/checkunusedvar.cpp | 4 +++- test/testunusedvar.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index e8d8ac958..77662060b 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -897,8 +897,10 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const if (tok && tok->isAssignmentOp() && tok->str() != "=") { variables.use(varid1, tok); - if (Token::Match(tok, "%assign% %name%")) + if (Token::Match(tok, "%assign% %name%")) { tok = tok->next(); + variables.read(tok->varId(), tok); + } } if (pre || post) diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 38d3be21f..974ba22d5 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -3153,6 +3153,13 @@ private: " return a;\n" "}"); ASSERT_EQUALS("", errout.str()); + + functionVariableUsage("void f() {\n" + " Fred fred;\n" + " int *a; a = b;\n" + " fred += a;\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void localvarFor() {