diff --git a/src/checkother.cpp b/src/checkother.cpp index 6ae5fb0f9..afda33446 100644 --- a/src/checkother.cpp +++ b/src/checkother.cpp @@ -520,6 +520,7 @@ void CheckOther::CheckVariableScope() continue; if ((tok1->str() == "return") || + (tok1->str() == "throw") || (tok1->str() == "delete") || (tok1->str() == "goto") || (tok1->str() == "else")) diff --git a/test/testother.cpp b/test/testother.cpp index 1c8fb4d05..93f4499c8 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -52,6 +52,7 @@ private: TEST_CASE(returnLocalVariable1); TEST_CASE(varScope1); + TEST_CASE(varScope2); } void check(const char code[]) @@ -314,6 +315,17 @@ private: "}\n"); ASSERT_EQUALS(std::string(""), errout.str()); } + + void varScope2() + { + varScope("int foo()\n" + "{\n" + " Error e;\n" + " e.SetValue(12);\n" + " throw e;\n" + "}\n"); + ASSERT_EQUALS(std::string(""), errout.str()); + } }; REGISTER_TEST(TestOther)