diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d961a9f6e..cf5303a2c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8106,6 +8106,8 @@ void Tokenizer::reportUnknownMacros() const else unknownMacroError(tok); } + } else if (isCPP() && Token::Match(tok, "public|private|protected %name% :")) { + unknownMacroError(tok->next()); } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index af455a0cf..6dcf245be 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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."); }