Tokenizer: improved simplification of numeric calculations

This commit is contained in:
Daniel Marjamäki 2012-09-09 16:22:39 +02:00
parent d44f10fc01
commit 7acb04b44c
2 changed files with 3 additions and 3 deletions

View File

@ -681,7 +681,7 @@ void TemplateSimplifier::simplifyTemplatesExpandTemplate(
static bool isLowerThanOr(const Token* lower)
{
return lower->isAssignmentOp() || Token::Match(lower, ";|(|[|]|)|,|?|:|%oror%|&&|return|throw|case");
return lower->isAssignmentOp() || Token::Match(lower, "}|;|(|[|]|)|,|?|:|%oror%|&&|return|throw|case");
}
static bool isLowerThanXor(const Token* lower)
{

View File

@ -7151,7 +7151,7 @@ private:
void enum29() { // #3747 - bitwise or value
const char code[] = "enum { x=1, y=x|2 }; i = (3==y);";
ASSERT_EQUALS("i = 3 == 1 | 2 ;", checkSimplifyEnum(code));
ASSERT_EQUALS("i = 3 == 3 ;", checkSimplifyEnum(code));
}
void enum30() { // #3852 - false positive
@ -7181,7 +7181,7 @@ private:
void enum32() { // #3998 - wrong enum simplification => access violation
const char code[] = "enum { x=(32), y=x, z }; { a, z }";
ASSERT_EQUALS("{ a , 32 + 1 }", checkSimplifyEnum(code));
ASSERT_EQUALS("{ a , 33 }", checkSimplifyEnum(code));
}
void enum33() { // #4015 - segmentation fault