diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index cd00d1b28..823d2a85f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4504,8 +4504,8 @@ void Tokenizer::simplifyFlowControl() } eraseDeadCode(tok, beginindent->link()); - } else if (tok->str() == "return") { - //catch the first ';' after the return + } else if (tok->str() == "return" || tok->str() == "throw") { + //catch the first ';' after the return|trow statement for (Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) { if (tok2->str() == "(" || tok2->str() == "[") { tok2 = tok2->link(); diff --git a/lib/tokenize.h b/lib/tokenize.h index e62ebe4e0..eeb37c57e 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -372,7 +372,7 @@ public: void simplifyGoto(); /** Simplify redundant code placed after control flow statements : - * 'return', 'goto', 'break' and 'continue' + * 'return', 'throw', 'goto', 'break' and 'continue' */ void simplifyFlowControl(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 7c8924b96..c14bef598 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -3085,8 +3085,7 @@ private: void flowControl() { std::list beforedead; beforedead.push_back("return"); - beforedead.push_back("return 0"); - beforedead.push_back("return -1"); + beforedead.push_back("throw ( 10 )"); beforedead.push_back("goto labels"); beforedead.push_back("break"); beforedead.push_back("continue");