Fixed #2307 (No constructor defined false positive when class is enclosed in namespace)

This commit is contained in:
Daniel Marjamäki 2010-12-17 20:56:46 +01:00
parent e0a0ed6fac
commit 845d1491f9
2 changed files with 21 additions and 1 deletions

View File

@ -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();

View File

@ -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()
{