Fixed #1341 (false positive 'uninitialized variable' when using Exception specifications)

This commit is contained in:
Daniel Marjamäki 2010-02-02 19:56:41 +01:00
parent a5dd99bc8c
commit 4ec94116f5
2 changed files with 31 additions and 5 deletions

View File

@ -5710,10 +5710,10 @@ void Tokenizer::removeExceptionSpecifications(Token *tok) const
else if (tok->str() == "}")
break;
else if (Token::Match(tok, ") throw ("))
else if (Token::simpleMatch(tok, ") throw ("))
{
while (tok->next() && !Token::Match(tok->next(), "[;{]"))
tok->deleteNext();
Token::eraseTokens(tok, tok->tokAt(2)->link());
tok->deleteNext();
}
else if (Token::Match(tok, "class %type%"))

View File

@ -174,7 +174,8 @@ private:
TEST_CASE(createLinks);
TEST_CASE(signed1);
TEST_CASE(removeExceptionSpecification);
TEST_CASE(removeExceptionSpecification1);
TEST_CASE(removeExceptionSpecification2);
TEST_CASE(gt); // use "<" comparisons instead of ">"
@ -2783,7 +2784,7 @@ private:
}
}
void removeExceptionSpecification()
void removeExceptionSpecification1()
{
const char code[] = "class A\n"
"{\n"
@ -2804,6 +2805,31 @@ private:
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
void removeExceptionSpecification2()
{
const char code[] = "class A\n"
"{\n"
"private:\n"
" int value;\n"
"public:\n"
" A::A() throw ()\n"
" : value(0)\n"
" { }\n"
"};\n";
const char expected[] = "class A\n"
"{\n"
"private:\n"
"int value ;\n"
"public:\n"
"A :: A ( )\n"
": value ( 0 )\n"
"{ }\n"
"} ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
void gt()
{