Fixed #1337 (Division by zero with __alignof__())
This commit is contained in:
parent
d3b5889f88
commit
0ba665d77f
|
@ -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));
|
||||
|
|
|
@ -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);"));
|
||||
|
|
Loading…
Reference in New Issue