Tokenizer: Report unknown macro that contains '.x=..' argument
This commit is contained in:
parent
efb583e3d1
commit
e0acd1abf8
|
@ -9337,6 +9337,19 @@ void Tokenizer::reportUnknownMacros()
|
|||
}
|
||||
}
|
||||
|
||||
// Report unknown macros that contain struct initialization "MACRO(a, .b=3)"
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (!Token::Match(tok, "%name% ("))
|
||||
continue;
|
||||
const Token *endTok = tok->linkAt(1);
|
||||
for (const Token *inner = tok->tokAt(2); inner != endTok; inner = inner->next()) {
|
||||
if (Token::Match(inner, "[[({]"))
|
||||
inner = inner->link();
|
||||
else if (Token::Match(inner->previous(), "[,(] . %name% ="))
|
||||
unknownMacroError(tok);
|
||||
}
|
||||
}
|
||||
|
||||
// Report unknown macros in non-executable scopes..
|
||||
std::set<std::string> possible;
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -8002,6 +8002,9 @@ private:
|
|||
" EVALUATE(123, int x=a; int y=b+c;);\n"
|
||||
"}";
|
||||
ASSERT_THROW(tokenizeAndStringify(code5), InternalError);
|
||||
|
||||
const char code6[] = "void foo() { dostuff(a, .x=0); }";
|
||||
ASSERT_THROW(tokenizeAndStringify(code6), InternalError);
|
||||
}
|
||||
|
||||
void findGarbageCode() { // Test Tokenizer::findGarbageCode()
|
||||
|
|
Loading…
Reference in New Issue