diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-14 15:44:01 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-15 19:20:21 +0300 |
commit | d2242c353fac9b76437b2c3bc521c0e6e415f3b1 (patch) | |
tree | 75d7554bb1451877bb682699215d30ab1ba59d76 /tests/auto/tools/moc/tst_moc.cpp | |
parent | 328680b34bc9d37bbfb42e188d9f943c07b5d5d0 (diff) |
MOC: pass the erroneous Symbol as an arg to Parser::error() overload
We already know the Symbol while parsing, passing a reference to it to
error() makes it simpler to construct the error message.
This fixes an issue where reporting an error about "NONSENSE" in e.g.:
Q_PROPERTY(Foo* foo NONSENSE foo)
would be off-by-one and the error message would say:
path/to/file.h:11:1: error: Parse error at "foo"
instead of 'at "NONSENSE"', which is where the parser actually found an
unexpected attribute.
Fixes: QTBUG-36367
Pick-to: 6.5
Change-Id: Ief70e544af41f7575fbeea9b936fa8197c3ef43d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 40d42a662b..b0cc42c6b6 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -62,6 +62,8 @@ #include "qmlmacro.h" +using namespace Qt::StringLiterals; + #ifdef Q_MOC_RUN // check that moc can parse these constructs, they are being used in Windows winsock2.h header #define STRING_HASH_HASH(x) ("foo" ## x ## "bar") @@ -2371,6 +2373,13 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:3:1: error: Parse error at \"decltype\""); + QTest::newRow("QTBUG-36367: report correct error location") + << "class X { \n Q_PROPERTY(Foo* foo NONSENSE foo) \n };"_ba + << QStringList() + << 1 + << QString() + << u"standard input:2:1: error: Parse error at \"NONSENSE\""_s; + #ifdef Q_OS_UNIX // Limit to Unix because the error message is platform-dependent QTest::newRow("Q_PLUGIN_METADATA: unreadable file") << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \".\") \n };") |