Preprocessor: Fixed TODO_ASSERT_EQUALS

This commit is contained in:
Daniel Marjamäki 2009-12-11 22:32:44 +01:00
parent 4d185f0935
commit c6f913ac3e
2 changed files with 17 additions and 3 deletions

View File

@ -920,7 +920,21 @@ void Preprocessor::simplifyCondition(const std::map<std::string, std::string> &v
}
// simplify calculations..
tokenizer.simplifyCalculations();
bool modified = true;
while (modified)
{
modified = false;
tokenizer.simplifyCalculations();
for (Token *tok = const_cast<Token *>(tokenizer.tokens()); tok; tok = tok->next())
{
if (Token::Match(tok, "! %num%"))
{
tok->deleteThis();
tok->str(tok->str() == "0" ? "1" : "0");
modified = true;
}
}
}
if (Token::simpleMatch(tokenizer.tokens(), "( 1 )") ||
Token::simpleMatch(tokenizer.tokens(), "( 1 ||"))

View File

@ -611,10 +611,10 @@ private:
cfg["ABC"] = "";
ASSERT_EQUALS(false, Preprocessor::match_cfg_def(cfg, "defined(A)"));
TODO_ASSERT_EQUALS(true, Preprocessor::match_cfg_def(cfg, "!defined(A)"));
ASSERT_EQUALS(true, Preprocessor::match_cfg_def(cfg, "!defined(A)"));
ASSERT_EQUALS(false, Preprocessor::match_cfg_def(cfg, "!defined(ABC)&&!defined(DEF)"));
TODO_ASSERT_EQUALS(true, Preprocessor::match_cfg_def(cfg, "!defined(A)&&!defined(B)"));
ASSERT_EQUALS(true, Preprocessor::match_cfg_def(cfg, "!defined(A)&&!defined(B)"));
}
{