diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7a8408db0..fdfd84202 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7900,7 +7900,7 @@ void Tokenizer::removeExceptionSpecifications(Token *tok) const tok->deleteNext(); } - else if (Token::Match(tok, "class %type%")) + else if (Token::Match(tok, "class|namespace|struct %type%")) { while (tok && !Token::Match(tok, "[;{]")) tok = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 142214609..50fda2caa 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -235,6 +235,7 @@ private: TEST_CASE(removeExceptionSpecification1); TEST_CASE(removeExceptionSpecification2); + TEST_CASE(removeExceptionSpecification3); TEST_CASE(gt); // use "<" comparisons instead of ">" @@ -4200,6 +4201,25 @@ private: ASSERT_EQUALS(expected, tokenizeAndStringify(code)); } + void removeExceptionSpecification3() + { + const char code[] = "namespace A {\n" + " struct B {\n" + " B() throw ()\n" + " { }\n" + " };\n" + "};\n"; + + const char expected[] = "namespace A {\n" + "struct B {\n" + "B ( )\n" + "{ }\n" + "} ;\n" + "} ;"; + + ASSERT_EQUALS(expected, tokenizeAndStringify(code)); + } + void gt() {