Skip to content

Commit

Permalink
Fix #11814 FP unknownMacro with designated initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 7, 2023
1 parent 2eac95f commit b9acaab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8058,7 +8058,7 @@ void Tokenizer::reportUnknownMacros() const

// Report unknown macros before } "{ .. if (x) MACRO }"
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, ")|; %name% }")) {
if (Token::Match(tok, ")|; %name% } !!)")) {
const Token* prev = tok->linkAt(2);
while (Token::simpleMatch(prev, "{"))
prev = prev->previous();
Expand Down
4 changes: 4 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6876,6 +6876,10 @@ class TestTokenizer : public TestFixture {

ASSERT_THROW(tokenizeAndStringify("void foo() { if(x) SYSTEM_ERROR }"), InternalError);
ASSERT_THROW(tokenizeAndStringify("void foo() { dostuff(); SYSTEM_ERROR }"), InternalError);

ASSERT_NO_THROW(tokenizeAndStringify("void f(void* q) {\n"
" g(&(S) { .p = (int*)q });\n"
"}\n", /*expand*/ true, cppcheck::Platform::Type::Native, "test.c"));
}

void findGarbageCode() { // Test Tokenizer::findGarbageCode()
Expand Down

0 comments on commit b9acaab

Please sign in to comment.