Preprocessor: support for ##-comma-eating in variadic macros; passing now fmt2 test.
This commit is contained in:
parent
127a910516
commit
de80baeea1
|
@ -645,6 +645,7 @@ public:
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
if (tok)
|
if (tok)
|
||||||
{
|
{
|
||||||
|
bool optcomma = false;
|
||||||
while ((tok = tok->next()) != NULL)
|
while ((tok = tok->next()) != NULL)
|
||||||
{
|
{
|
||||||
std::string str = tok->str();
|
std::string str = tok->str();
|
||||||
|
@ -667,8 +668,9 @@ public:
|
||||||
str = "";
|
str = "";
|
||||||
for (unsigned int j = _params.size() - 1; j < params2.size(); ++j)
|
for (unsigned int j = _params.size() - 1; j < params2.size(); ++j)
|
||||||
{
|
{
|
||||||
if (j > _params.size() - 1)
|
if (optcomma || j > _params.size() - 1)
|
||||||
str += ",";
|
str += ",";
|
||||||
|
optcomma = false;
|
||||||
str += params2[j];
|
str += params2[j];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -681,6 +683,12 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_variadic && Token::Match(tok, ",") && tok->next() && Token::Match(tok->next(), "##"))
|
||||||
|
{
|
||||||
|
optcomma = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
optcomma = false;
|
||||||
macrocode += str;
|
macrocode += str;
|
||||||
if (Token::Match(tok, "%type% %var%"))
|
if (Token::Match(tok, "%type% %var%"))
|
||||||
macrocode += " ";
|
macrocode += " ";
|
||||||
|
|
|
@ -102,7 +102,7 @@ private:
|
||||||
TEST_CASE(preprocessor_doublesharp);
|
TEST_CASE(preprocessor_doublesharp);
|
||||||
TEST_CASE(preprocessor_include_in_str);
|
TEST_CASE(preprocessor_include_in_str);
|
||||||
TEST_CASE(fmt1);
|
TEST_CASE(fmt1);
|
||||||
// TODO TEST_CASE(fmt2);
|
TEST_CASE(fmt2);
|
||||||
TEST_CASE(multi_character_character);
|
TEST_CASE(multi_character_character);
|
||||||
|
|
||||||
TEST_CASE(stringify);
|
TEST_CASE(stringify);
|
||||||
|
|
Loading…
Reference in New Issue