Fixed #1337 (Division by zero with __alignof__())

This commit is contained in:
Daniel Marjamäki 2010-02-03 21:23:44 +01:00
parent d3b5889f88
commit 0ba665d77f
2 changed files with 14 additions and 2 deletions

View File

@ -5048,7 +5048,7 @@ void Tokenizer::simplifyEnum()
Token * enumName = 0;
Token * enumValue = 0;
if (Token::Match(tok1, "%type% ,|}"))
if (Token::Match(tok1->previous(), ",|{ %type% ,|}"))
{
enumName = tok1;
last_value++;
@ -5057,7 +5057,7 @@ void Tokenizer::simplifyEnum()
tok1->insertToken(MathLib::toString<long>(last_value).c_str());
enumValue = tok1->next();
}
else if (Token::Match(tok1, "%type% = %num% ,|}"))
else if (Token::Match(tok1->previous(), ",|{ %type% = %num% ,|}"))
{
enumName = tok1;
last_value = std::atoi(tok1->strAt(2));

View File

@ -186,6 +186,7 @@ private:
TEST_CASE(enum2);
TEST_CASE(enum3);
TEST_CASE(enum4);
TEST_CASE(enum5);
// remove "std::" on some standard functions
TEST_CASE(removestd);
@ -3451,6 +3452,17 @@ private:
}
}
void enum5()
{
const char code[] = "enum ABC {\n"
" a = sizeof(int),\n"
" b = 1 + a,\n"
" c = b + 100\n"
"}; a b c";
ASSERT_EQUALS("; a b c", tok(code, false));
TODO_ASSERT_EQUALS("; 4 5 105", tok(code, false));
}
void removestd()
{
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));