Fixed #1355 (Fixed enum bug when expression contain comma)
This commit is contained in:
parent
cbc853fdba
commit
b78845174d
|
@ -5110,10 +5110,20 @@ void Tokenizer::simplifyEnum()
|
|||
tok1 = tok1->tokAt(2);
|
||||
enumValueStart = tok1;
|
||||
enumValueEnd = tok1;
|
||||
while (!Token::Match(enumValueEnd->next(), ",|}"))
|
||||
int level = 0;
|
||||
while (enumValueEnd->next() && (enumValueEnd->next()->str() != "}") &&
|
||||
((enumValueEnd->next()->str() != ",") || level))
|
||||
{
|
||||
if (enumValueEnd->next()->str() == "(" || enumValueEnd->next()->str() == "[")
|
||||
level++;
|
||||
else if (enumValueEnd->next()->str() == ")" || enumValueEnd->next()->str() == "]")
|
||||
level--;
|
||||
|
||||
enumValueEnd = enumValueEnd->next();
|
||||
}
|
||||
lastEnumValueStart = enumValueStart;
|
||||
lastEnumValueEnd = enumValueEnd;
|
||||
tok1 = enumValueEnd;
|
||||
}
|
||||
|
||||
if (enumName && (enumValue || (enumValueStart && enumValueEnd)))
|
||||
|
|
|
@ -187,6 +187,7 @@ private:
|
|||
TEST_CASE(enum3);
|
||||
TEST_CASE(enum4);
|
||||
TEST_CASE(enum5);
|
||||
TEST_CASE(enum6);
|
||||
|
||||
// remove "std::" on some standard functions
|
||||
TEST_CASE(removestd);
|
||||
|
@ -3478,6 +3479,13 @@ private:
|
|||
ASSERT_EQUALS("; int sum ; sum = 508 ;", tok(code, true));
|
||||
}
|
||||
|
||||
void enum6()
|
||||
{
|
||||
const char code[] = "enum { a = MAC(A, B, C) }; void f(a) { }";
|
||||
const char expected[] = "; void f ( MAC ( A , B , C ) ) { }";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
void removestd()
|
||||
{
|
||||
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));
|
||||
|
|
Loading…
Reference in New Issue