Tokenizer; Warn about unknown macro used in string concatenation

This commit is contained in:
Daniel Marjamäki 2020-02-28 21:51:49 +01:00
parent bf781f79b6
commit 5df6d5bc7c
2 changed files with 12 additions and 0 deletions

View File

@ -9332,6 +9332,15 @@ void Tokenizer::reportUnknownMacros()
} }
} }
} }
// String concatenation with unknown macros
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, "%str% %name% (") && Token::Match(tok->linkAt(2), ") %str%")) {
if (list.isKeyword(tok->next()->str()))
continue;
unknownMacroError(tok->next());
}
}
} }
void Tokenizer::findGarbageCode() const void Tokenizer::findGarbageCode() const

View File

@ -7982,6 +7982,9 @@ private:
const char code2[] = "void foo() { dostuff(x 0); }"; const char code2[] = "void foo() { dostuff(x 0); }";
ASSERT_THROW(tokenizeAndStringify(code2), InternalError); ASSERT_THROW(tokenizeAndStringify(code2), InternalError);
const char code3[] = "f(\"1\" __stringify(48) \"1\");";
ASSERT_THROW(tokenizeAndStringify(code3), InternalError);
} }
void findGarbageCode() { // Test Tokenizer::findGarbageCode() void findGarbageCode() { // Test Tokenizer::findGarbageCode()