Tokenizer: improved simplification of numeric calculations
This commit is contained in:
parent
d44f10fc01
commit
7acb04b44c
|
@ -681,7 +681,7 @@ void TemplateSimplifier::simplifyTemplatesExpandTemplate(
|
||||||
|
|
||||||
static bool isLowerThanOr(const Token* lower)
|
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)
|
static bool isLowerThanXor(const Token* lower)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7151,7 +7151,7 @@ private:
|
||||||
|
|
||||||
void enum29() { // #3747 - bitwise or value
|
void enum29() { // #3747 - bitwise or value
|
||||||
const char code[] = "enum { x=1, y=x|2 }; i = (3==y);";
|
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
|
void enum30() { // #3852 - false positive
|
||||||
|
@ -7181,7 +7181,7 @@ private:
|
||||||
|
|
||||||
void enum32() { // #3998 - wrong enum simplification => access violation
|
void enum32() { // #3998 - wrong enum simplification => access violation
|
||||||
const char code[] = "enum { x=(32), y=x, z }; { a, z }";
|
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
|
void enum33() { // #4015 - segmentation fault
|
||||||
|
|
Loading…
Reference in New Issue