summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-05-14 15:44:01 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-05-15 18:06:47 +0000
commit3afa4b2666f25c9aaef03598d7aec3c4993b97c2 (patch)
treea9929e5e1910470f569e02d41d1080535e4593a9 /tests
parent65528387dcea70d65a8391f987919c01b7603079 (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 Change-Id: Ief70e544af41f7575fbeea9b936fa8197c3ef43d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit d2242c353fac9b76437b2c3bc521c0e6e415f3b1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp9
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 123bc0bfd3..8d83c1d3b4 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -60,6 +60,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")
@@ -2296,6 +2298,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 };")