Fixed #4079 (#if condition does not evaluate numbers with sign)

This commit is contained in:
Daniel Marjamäki 2012-11-28 07:33:24 +01:00
parent 5d1b4e6dbb
commit 7d94230329
2 changed files with 11 additions and 0 deletions

View File

@ -1450,6 +1450,7 @@ void Preprocessor::simplifyCondition(const std::map<std::string, std::string> &c
} }
// simplify calculations.. // simplify calculations..
tokenizer.concatenateNegativeNumber();
bool modified = true; bool modified = true;
while (modified) { while (modified) {
modified = false; modified = false;

View File

@ -222,6 +222,7 @@ private:
TEST_CASE(define_if1); TEST_CASE(define_if1);
TEST_CASE(define_if2); TEST_CASE(define_if2);
TEST_CASE(define_if3); TEST_CASE(define_if3);
TEST_CASE(define_if4); // #4079 - #define X +123
TEST_CASE(define_ifdef); TEST_CASE(define_ifdef);
TEST_CASE(define_ifndef1); TEST_CASE(define_ifndef1);
TEST_CASE(define_ifndef2); TEST_CASE(define_ifndef2);
@ -2695,6 +2696,15 @@ private:
ASSERT_EQUALS("\n\nFOO\n\n", preprocessor.getcode(filedata,"","")); ASSERT_EQUALS("\n\nFOO\n\n", preprocessor.getcode(filedata,"",""));
} }
void define_if4() {
const char filedata[] = "#define X +123\n"
"#if X==123\n"
"FOO\n"
"#endif";
Preprocessor preprocessor(NULL, this);
ASSERT_EQUALS("\n\nFOO\n\n", preprocessor.getcode(filedata,"",""));
}
void define_ifdef() { void define_ifdef() {
{ {
const char filedata[] = "#define ABC\n" const char filedata[] = "#define ABC\n"