diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 6993cd19f..be425eaf0 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1128,7 +1128,7 @@ void CheckOther::functionVariableUsage() if (tok->str() == "const") tok = tok->next(); - if (tok->str() != "return") + if (tok->str() != "return" && tok->str() != "throw") { Variables::VariableType type; diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 799557e2e..5666c679e 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -69,6 +69,7 @@ private: TEST_CASE(localvar21); // ticket #1807 TEST_CASE(localvar22); // ticket #1811 TEST_CASE(localvar23); // ticket #1808 + TEST_CASE(localvar24); // ticket #1803 TEST_CASE(localvaralias1); TEST_CASE(localvaralias2); // ticket #1637 TEST_CASE(localvaralias3); // ticket #1639 @@ -1216,6 +1217,18 @@ private: ASSERT_EQUALS("", errout.str()); } + void localvar24() // ticket #1803 + { + functionVariableUsage("class MyException\n" + "{\n" + " virtual void raise() const\n" + " {\n" + " throw *this;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void localvaralias1() { functionVariableUsage("void foo()\n"