diff options
-rw-r--r-- | src/tools/moc/moc.cpp | 7 | ||||
-rw-r--r-- | src/tools/moc/parser.cpp | 9 | ||||
-rw-r--r-- | src/tools/moc/parser.h | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index e0671587840..b6671f6e126 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1931,13 +1931,10 @@ void Moc::checkProperties(ClassDef *cdef) } if (p.read.isEmpty() && p.member.isEmpty() && p.bind.isEmpty()) { - const qsizetype rewind = index; - if (p.location >= 0) - index = p.location; QByteArray msg = "Property declaration " + p.name + " has neither an associated QProperty<> member" ", nor a READ accessor function nor an associated MEMBER variable. The property will be invalid."; - warning(msg.constData()); - index = rewind; + const auto &sym = p.location >= 0 ? symbolAt(p.location) : Symbol(); + warning(sym, msg.constData()); if (p.write.isEmpty()) { cdef->propertyList.removeAt(i); --i; diff --git a/src/tools/moc/parser.cpp b/src/tools/moc/parser.cpp index f1493518f82..ab3131f7325 100644 --- a/src/tools/moc/parser.cpp +++ b/src/tools/moc/parser.cpp @@ -73,9 +73,14 @@ void Parser::error(const char *msg) exit(EXIT_FAILURE); } +void Parser::warning(const Symbol &sym, QByteArrayView msg) +{ + if (displayWarnings) + printMsg("warning: %s\n", msg, sym); +} + void Parser::warning(const char *msg) { - if (displayWarnings && msg) - printMsg("warning: %s\n", msg, index > 0 ? symbol() : Symbol{}); + warning(index > 0 ? symbol() : Symbol{}, msg); } void Parser::note(const char *msg) { diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h index 7b5c604a715..6fe982a1ce7 100644 --- a/src/tools/moc/parser.h +++ b/src/tools/moc/parser.h @@ -44,10 +44,12 @@ public: inline QByteArray lexem() { return symbols.at(index-1).lexem();} inline QByteArray unquotedLexem() { return symbols.at(index-1).unquotedLexem();} inline const Symbol &symbol() { return symbols.at(index-1);} + inline const Symbol &symbolAt(qsizetype idx) { return symbols.at(idx); } Q_NORETURN void error(const Symbol &symbol); Q_NORETURN void error(const char *msg = nullptr); void warning(const char * = nullptr); + void warning(const Symbol &sym, QByteArrayView msg); void note(const char * = nullptr); void defaultErrorMsg(const Symbol &sym); void printMsg(QByteArrayView formatStringSuffix, QByteArrayView msg, const Symbol &sym); |