Fixed #1951 (Preprocessor: Compound macro statements not handled correctly)
This commit is contained in:
parent
499a12c896
commit
1d9e484053
|
@ -1104,10 +1104,13 @@ void Preprocessor::simplifyCondition(const std::map<std::string, std::string> &v
|
|||
const std::map<std::string, std::string>::const_iterator it = variables.find(tok->str());
|
||||
if (it != variables.end())
|
||||
{
|
||||
if (it->second.empty())
|
||||
tok->deleteThis();
|
||||
else
|
||||
if (!it->second.empty())
|
||||
tok->str(it->second);
|
||||
else if ((!tok->previous() || tok->strAt(-1) == "||" || tok->strAt(-1) == "&&" || tok->strAt(-1) == "(") &&
|
||||
(!tok->next() || tok->strAt(1) == "||" || tok->strAt(1) == "&&" || tok->strAt(-1) == ")"))
|
||||
tok->str("1");
|
||||
else
|
||||
tok->deleteThis();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,8 @@ private:
|
|||
TEST_CASE(if_cond9);
|
||||
TEST_CASE(if_cond10);
|
||||
|
||||
TEST_CASE(if_or);
|
||||
TEST_CASE(if_or_1);
|
||||
TEST_CASE(if_or_2);
|
||||
|
||||
TEST_CASE(multiline1);
|
||||
TEST_CASE(multiline2);
|
||||
|
@ -1068,7 +1069,7 @@ private:
|
|||
|
||||
|
||||
|
||||
void if_or()
|
||||
void if_or_1()
|
||||
{
|
||||
const char filedata[] = "#if defined(DEF_10) || defined(DEF_11)\n"
|
||||
"a1;\n"
|
||||
|
@ -1097,6 +1098,15 @@ private:
|
|||
|
||||
}
|
||||
|
||||
void if_or_2()
|
||||
{
|
||||
const std::string code("#if X || Y\n"
|
||||
"a1;\n"
|
||||
"#endif\n");
|
||||
const std::string actual = Preprocessor::getcode(code, "X", "test.c", NULL);
|
||||
ASSERT_EQUALS("\na1;\n\n", actual);
|
||||
}
|
||||
|
||||
|
||||
void multiline1()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue