Fixed #9730 (Regression: TEXT macro not handled in windows code)

This commit is contained in:
Daniel Marjamäki 2020-05-28 22:03:01 +02:00
parent 79c3af56e4
commit 7ff692341e
2 changed files with 15 additions and 4 deletions

View File

@ -2484,14 +2484,19 @@ void Tokenizer::combineOperators()
void Tokenizer::combineStringAndCharLiterals()
{
// Combine strings
for (Token *tok = list.front();
tok;
tok = tok->next()) {
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (!isStringLiteral(tok->str()))
continue;
tok->str(simplifyString(tok->str()));
while (tok->next() && tok->next()->tokType() == Token::eString) {
while (Token::Match(tok->next(), "%str%") || Token::Match(tok->next(), "_T|_TEXT|TEXT ( %str% )")) {
if (tok->next()->isName()) {
if (!mSettings->isWindowsPlatform())
break;
tok->deleteNext(2);
tok->next()->deleteNext();
}
// Two strings after each other, combine them
tok->concatStr(simplifyString(tok->next()->str()));
tok->deleteNext();

View File

@ -1800,6 +1800,12 @@ private:
"};\n"
"}\n";
ASSERT_EQUALS(tok(code2), tok(code1));
const char code3[] = "x = L\"1\" TEXT(\"2\") L\"3\";";
ASSERT_EQUALS("x = L\"123\" ;", tok(code3, false, Settings::Win64));
const char code4[] = "x = TEXT(\"1\") L\"2\";";
ASSERT_EQUALS("x = L\"1\" L\"2\" ;", tok(code4, false, Settings::Win64));
}
void combine_wstrings() {