From 2bb07a55bd8a56b1c296d29c6aec35e3326093f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 7 Jul 2010 08:39:18 +0200 Subject: [PATCH] Fixed #1803 (False positive: unused variable: this) --- lib/checkother.cpp | 2 +- test/testunusedvar.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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"