From 7e04ea0859215355ebbaa950aaa449c3b9822358 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Wed, 16 Mar 2011 19:54:52 -0400 Subject: [PATCH] fix removal of throw() from const functions --- lib/tokenize.cpp | 10 ++++++++-- test/testclass.cpp | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index dfeb252f5..b9bdfe11a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8558,9 +8558,15 @@ void Tokenizer::removeExceptionSpecifications(Token *tok) const else if (tok->str() == "}") break; - else if (Token::simpleMatch(tok, ") throw (")) + else if (Token::Match(tok, ") const| throw (")) { - Token::eraseTokens(tok, tok->tokAt(2)->link()); + if (tok->next()->str() == "const") + { + Token::eraseTokens(tok->next(), tok->tokAt(3)->link()); + tok = tok->next(); + } + else + Token::eraseTokens(tok, tok->tokAt(2)->link()); tok->deleteNext(); } diff --git a/test/testclass.cpp b/test/testclass.cpp index 7147ebee5..216af4e4e 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -3301,6 +3301,11 @@ private: " { return 0; }\n" "};\n"); ASSERT_EQUALS("", errout.str()); + + checkConst("class Fred {\n" + " const std::string foo() const throw() { return ""; }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void const2()