diff --git a/gui/checkstatistics.cpp b/gui/checkstatistics.cpp index dc92b4c7a..a8f75c9a8 100644 --- a/gui/checkstatistics.cpp +++ b/gui/checkstatistics.cpp @@ -41,22 +41,22 @@ void CheckStatistics::addItem(const QString &tool, ShowTypes::ShowType type) const QString lower = tool.toLower(); switch (type) { case ShowTypes::ShowStyle: - ::addItem(mStyle, tool); + ::addItem(mStyle, lower); break; case ShowTypes::ShowWarnings: - ::addItem(mWarning, tool); + ::addItem(mWarning, lower); break; case ShowTypes::ShowPerformance: - ::addItem(mPerformance, tool); + ::addItem(mPerformance, lower); break; case ShowTypes::ShowPortability: - ::addItem(mPortability, tool); + ::addItem(mPortability, lower); break; case ShowTypes::ShowErrors: - ::addItem(mError, tool); + ::addItem(mError, lower); break; case ShowTypes::ShowInformation: - ::addItem(mInformation, tool); + ::addItem(mInformation, lower); break; case ShowTypes::ShowNone: default: diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index ebf57b053..ab41ef548 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1361,7 +1361,7 @@ void CheckUnusedVar::checkFunctionVariableUsage() else if (!usage._var->isMaybeUnused() && !usage._modified && !usage._read && var) { const Token* vnt = var->nameToken(); bool error = false; - if (vnt->next()->isSplittedVarDeclEq()) { + if (vnt->next()->isSplittedVarDeclEq() || (!var->isReference() && vnt->next()->str() == "=")) { const Token* nextStmt = vnt->tokAt(2); if (nextStmt->isExpandedMacro()) { const Token* parent = nextStmt; diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 839ea34e6..4a81d3f4b 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -5689,9 +5689,8 @@ private: "{\n" " static int i = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", - "", - errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", + errout.str()); functionVariableUsage("void foo()\n" "{\n" @@ -6305,6 +6304,15 @@ private: " const ::std::lock_guard g(m);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + functionVariableUsage("void f(const std::string& str, int i) {\n" // #11879 + " const std::string s = str;\n" + " switch (i) {\n" + " default:\n" + " break;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", errout.str()); } void localVarClass() {