Skip to content

Commit

Permalink
Fix FP unknownMacro
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 17, 2023
1 parent c0bd9f8 commit ce14070
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8059,6 +8059,8 @@ 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 (tok->link() && !Token::simpleMatch(tok->link()->tokAt(-1), "if"))
continue;
const Token* prev = tok->linkAt(2);
while (Token::simpleMatch(prev, "{"))
prev = prev->previous();
Expand Down
5 changes: 5 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6880,6 +6880,11 @@ class TestTokenizer : public TestFixture {
ASSERT_NO_THROW(tokenizeAndStringify("void f(void* q) {\n"
" g(&(S) { .p = (int*)q });\n"
"}\n", /*expand*/ true, cppcheck::Platform::Type::Native, "test.c"));

ASSERT_NO_THROW(tokenizeAndStringify("typedef struct { int i; } S;\n"
"void f(float a) {\n"
"S s = (S){ .i = (int)a };\n"
"}\n", /*expand*/ true, cppcheck::Platform::Type::Native, "test.c"));
}

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

0 comments on commit ce14070

Please sign in to comment.