Fixed #2794 (Improper hanling of preprocessor directives #if defined)
This commit is contained in:
parent
f0a7cc5961
commit
7e7f6eecf5
|
@ -7627,6 +7627,7 @@ bool Tokenizer::simplifyCalculations()
|
|||
tok = tok->previous();
|
||||
tok->deleteThis();
|
||||
tok->deleteThis();
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "%num% ==|!=|<=|>=|<|> %num%") &&
|
||||
|
|
|
@ -227,6 +227,9 @@ private:
|
|||
TEST_CASE(predefine1);
|
||||
TEST_CASE(predefine2);
|
||||
TEST_CASE(predefine3);
|
||||
|
||||
// Test Preprocessor::simplifyCondition
|
||||
TEST_CASE(simplifyCondition);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2913,6 +2916,16 @@ private:
|
|||
const std::string actual = Preprocessor::getcode(code, "TEST", "test.c", &settings, this);
|
||||
ASSERT_EQUALS("\n\n\nFred & Wilma\n\n", actual);
|
||||
}
|
||||
|
||||
void simplifyCondition()
|
||||
{
|
||||
// Ticket #2794
|
||||
std::map<std::string, std::string> cfg;
|
||||
cfg["C"] = "";
|
||||
std::string condition("defined(A) || defined(B) || defined(C)");
|
||||
Preprocessor::simplifyCondition(cfg, condition, true);
|
||||
ASSERT_EQUALS("1", condition);
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestPreprocessor)
|
||||
|
|
Loading…
Reference in New Issue