Fixed #1432 (false positive: uninitialized variable)

This commit is contained in:
Daniel Marjamäki 2010-03-06 13:48:43 +01:00
parent 237fdbc653
commit fe30c1ca9d
2 changed files with 14 additions and 2 deletions

View File

@ -5208,7 +5208,7 @@ void Tokenizer::simplifyGoto()
token->deleteNext();
// Insert the statements..
bool ret = false; // is there return
bool ret = false; // is there return
bool ret2 = false; // is there return in indentlevel 0
std::list<Token*> links;
std::list<Token*> links2;
@ -5749,7 +5749,7 @@ void Tokenizer::simplifyEnum()
{
// Don't replace this enum if it's preceded by "::"
}
else
else if (tok2->next()->isName())
{
simplifyEnum = true;
hasClass = false;

View File

@ -203,6 +203,7 @@ private:
TEST_CASE(enum9); // ticket 1404
TEST_CASE(enum10); // ticket 1445
TEST_CASE(enum11);
TEST_CASE(enum12);
// remove "std::" on some standard functions
TEST_CASE(removestd);
@ -3981,6 +3982,17 @@ private:
"[test.cpp:4] -> [test.cpp:3]: (style) Variable 'v' hides enumerator with same name\n", errout.str());
}
void enum12()
{
const char code[] = "enum fred { a, b };\n"
"void foo()\n"
"{\n"
" unsigned int fred = 0;\n"
"}";
const char expected[] = "; void foo ( ) { unsigned int fred ; fred = 0 ; }";
ASSERT_EQUALS(expected, tok(code, false));
}
void removestd()
{
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));