From e6a1efa13b8828c99fa38945952d97fc22ea1100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 16 Jan 2011 18:45:05 +0100 Subject: [PATCH] Fixed #2302 (Duplicate id 'unusedVariable') --- lib/checkother.cpp | 2 +- test/testcppcheck.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 1a17e0d2e..2caf92f66 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1875,7 +1875,7 @@ void CheckOther::unusedVariableError(const Token *tok, const std::string &varnam void CheckOther::allocatedButUnusedVariableError(const Token *tok, const std::string &varname) { - reportError(tok, Severity::style, "unusedVariable", "Variable '" + varname + "' is allocated memory that is never used"); + reportError(tok, Severity::style, "unusedAllocatedMemory", "Variable '" + varname + "' is allocated memory that is never used"); } void CheckOther::unreadVariableError(const Token *tok, const std::string &varname) diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 582a6376d..af6e33883 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -77,6 +77,18 @@ private: ASSERT(!errorLogger.id.empty()); // TODO: check if there are duplicate error ids in errorLogger.id + std::string duplicate; + for (std::list::iterator it = errorLogger.id.begin(); + it != errorLogger.id.end(); + ++it) + { + if (std::find(errorLogger.id.begin(), it, *it) != it) + { + duplicate = "Duplicate ID: " + *it; + break; + } + } + ASSERT_EQUALS("", duplicate); } };