Skip to content

Commit

Permalink
Fix #12010 Improve unknownMacro message: int (#5473)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Sep 22, 2023
1 parent 6fcf11b commit b745d9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8146,7 +8146,7 @@ static T* skipCPPOrAlignAttribute(T * tok)

static bool isNonMacro(const Token* tok)
{
if (tok->isKeyword())
if (tok->isKeyword() || tok->isStandardType())
return true;
if (cAlternativeTokens.count(tok->str()) > 0)
return true;
Expand Down Expand Up @@ -8272,7 +8272,7 @@ void Tokenizer::reportUnknownMacros() const
for (const Token* tok = tokens(); tok; tok = tok->next()) {
if (!Token::Match(tok, "%name% ("))
continue;
if (isNonMacro(tok))
if (isNonMacro(tok) && !tok->isStandardType())
continue;

const Token* endTok = tok->linkAt(1);
Expand All @@ -8288,7 +8288,7 @@ void Tokenizer::reportUnknownMacros() const
continue;
}

unknownMacroError(tok);
unknownMacroError(tok->isStandardType() ? tok2 : tok);
}
}

Expand Down
4 changes: 4 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7043,6 +7043,10 @@ class TestTokenizer : public TestFixture {
ASSERT_THROW_EQUALS(tokenizeAndStringify("void f() { MACRO(x(), y(), \"abc\", z(); ok = true); }\n"), // #12006
InternalError,
"There is an unknown macro here somewhere. Configuration is required. If MACRO is a macro then please configure it.");

ASSERT_THROW_EQUALS(tokenizeAndStringify("int (*f) MACRO((void *));\n"), // #12010
InternalError,
"There is an unknown macro here somewhere. Configuration is required. If MACRO is a macro then please configure it.");
}


Expand Down

0 comments on commit b745d9a

Please sign in to comment.