Fixed #3248 (Tokenizer: better handling of char constants that are compared with numeric constants)
This commit is contained in:
parent
73f3b2074b
commit
9b8ffe7219
|
@ -7272,6 +7272,11 @@ bool Tokenizer::simplifyCalculations()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (tok->str()[0] == '\'' && tok->str().size() == 3 &&
|
||||
Token::Match(tok->previous(), "(|&&|%oror% %any% ==|!=|<=|<|>=|> %num% &&|%oror%|)")) {
|
||||
tok->str(MathLib::toString(tok->str()[1] & 0xff));
|
||||
}
|
||||
|
||||
if (tok->isNumber()) {
|
||||
if (tok->str() == "0") {
|
||||
if (Token::Match(tok->previous(), "[+-|] 0")) {
|
||||
|
|
|
@ -123,6 +123,7 @@ private:
|
|||
TEST_CASE(if_cond10);
|
||||
TEST_CASE(if_cond11);
|
||||
TEST_CASE(if_cond12);
|
||||
TEST_CASE(if_cond13);
|
||||
|
||||
TEST_CASE(if_or_1);
|
||||
TEST_CASE(if_or_2);
|
||||
|
@ -1404,6 +1405,13 @@ private:
|
|||
ASSERT_EQUALS("\n\n;\n\n", Preprocessor::getcode(filedata,"","",NULL,NULL));
|
||||
}
|
||||
|
||||
void if_cond13() {
|
||||
const char filedata[] = "#if ('A' == 0x41)\n"
|
||||
"123\n"
|
||||
"#endif\n";
|
||||
ASSERT_EQUALS("\n123\n\n", Preprocessor::getcode(filedata,"","",NULL,NULL));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void if_or_1() {
|
||||
|
|
Loading…
Reference in New Issue