Fixed #1474 (segmentation fault of cppcheck)

This commit is contained in:
Daniel Marjamäki 2010-03-07 12:50:45 +01:00
parent 7f42ed3ad0
commit fa493b7fd1
2 changed files with 18 additions and 0 deletions

View File

@ -5517,6 +5517,12 @@ void Tokenizer::simplifyEnum()
Token * enumValueStart = 0;
Token * enumValueEnd = 0;
if (tok1->str() == "(")
{
tok1 = tok1->link();
continue;
}
if (Token::Match(tok1->previous(), ",|{ %type% ,|}"))
{
// no value specified

View File

@ -204,6 +204,7 @@ private:
TEST_CASE(enum10); // ticket 1445
TEST_CASE(enum11);
TEST_CASE(enum12);
TEST_CASE(enum13);
// remove "std::" on some standard functions
TEST_CASE(removestd);
@ -3996,6 +3997,17 @@ private:
ASSERT_EQUALS(expected, tok(code, false));
}
void enum13()
{
const char code[] = "enum ab { ENTRY(1, a = 0), ENTRY(2, b) };\n"
"void foo()\n"
"{\n"
" unsigned int fred = a;\n"
"}";
const char expected[] = "; void foo ( ) { unsigned int fred ; fred = a ; }";
ASSERT_EQUALS(expected, tok(code, false));
}
void removestd()
{
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));