Partial fix for #11770 cppcheckError with unknown macro

This commit is contained in:
chrchr 2023-06-15 18:36:21 +02:00
parent c033c62190
commit 9579b4509d
2 changed files with 10 additions and 0 deletions

View File

@ -8106,6 +8106,8 @@ void Tokenizer::reportUnknownMacros() const
else
unknownMacroError(tok);
}
} else if (isCPP() && Token::Match(tok, "public|private|protected %name% :")) {
unknownMacroError(tok->next());
}
}

View File

@ -6936,6 +6936,14 @@ private:
ASSERT_THROW_EQUALS(tokenizeAndStringify("int f() { MACRO(x) return 0; }"),
InternalError,
"There is an unknown macro here somewhere. Configuration is required. If MACRO is a macro then please configure it.");
ASSERT_THROW_EQUALS(tokenizeAndStringify("class C : public QObject {\n" // #11770
" struct S { static void g() {} };\n"
"private Q_SLOTS:\n"
" void f() { S::g(); }\n"
"};\n"),
InternalError,
"There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.");
}