From 845d1491f9726f79db184dfc92c8ed1e4c48c7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 17 Dec 2010 20:56:46 +0100 Subject: [PATCH] Fixed #2307 (No constructor defined false positive when class is enclosed in namespace) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) 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() {