aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-06 17:03:37 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-08-17 18:04:35 +0200
commit8edbcdbeb49630c207f3111d24b9c9e07029e333 (patch)
treeb1c6f0a88c19f69126e6915cdefab81c44fdab06
parent2ed0abd5533750343a382f5b4ab5dcab6d52eff2 (diff)
Mark the module as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses is high here, too high for this author, unfamiliar with this code, to tackle in a short amount of time. But they're concentrated in just a few TUs, so pick a different strategy: Mark the whole module with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). Created QTBUG-115808 to keep track of this. Task-number: QTBUG-115808 Change-Id: I29c377f939e3d747e3ce72c224c4ee722df7a95d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--.cmake.conf1
-rw-r--r--src/particles/CMakeLists.txt1
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/CMakeLists.txt2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp2
-rw-r--r--src/qmldebug/CMakeLists.txt2
-rw-r--r--src/qmldebug/qv4debugclient.cpp2
-rw-r--r--src/qmldom/CMakeLists.txt2
-rw-r--r--src/qmldom/qqmldomcodeformatter.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/CMakeLists.txt2
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/CMakeLists.txt2
-rw-r--r--tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/CMakeLists.txt2
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp1
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/CMakeLists.txt2
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/CMakeLists.txt2
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp2
-rw-r--r--tests/auto/qml/debugger/qv4debugger/CMakeLists.txt2
-rw-r--r--tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp3
-rw-r--r--tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp3
-rw-r--r--tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp2
-rw-r--r--tests/auto/qml/qqmlecmascript/CMakeLists.txt2
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp3
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp2
-rw-r--r--tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/CMakeLists.txt3
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp3
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp3
-rw-r--r--tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp3
-rw-r--r--tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp3
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp2
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp3
-rw-r--r--tests/auto/qml/qqmlvaluetypes/CMakeLists.txt2
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp2
-rw-r--r--tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp2
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp2
-rw-r--r--tests/auto/quick/qquickanchors/tst_qquickanchors.cpp3
-rw-r--r--tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp3
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp2
-rw-r--r--tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp3
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp3
-rw-r--r--tests/auto/quick/qquicklistview/CMakeLists.txt2
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp2
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp3
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp2
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp3
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp3
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp3
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp2
52 files changed, 118 insertions, 1 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 8b5401f057..d4121fee8d 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -3,3 +3,4 @@ set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1")
list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1")
+list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1")
diff --git a/src/particles/CMakeLists.txt b/src/particles/CMakeLists.txt
index 379a124e42..61a9c536ff 100644
--- a/src/particles/CMakeLists.txt
+++ b/src/particles/CMakeLists.txt
@@ -56,7 +56,6 @@ qt_internal_add_qml_module(QuickParticlesPrivate
qquickturbulence.cpp
# end undef QT_NO_FOREACH
DEFINES
- QT_NO_FOREACH
QT_NO_INTEGER_EVENT_COORDINATES
QT_NO_URL_CAST_FROM_STRING
PUBLIC_LIBRARIES
diff --git a/src/plugins/qmltooling/qmldbg_debugger/CMakeLists.txt b/src/plugins/qmltooling/qmldbg_debugger/CMakeLists.txt
index 7ff705995c..f75a667306 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/CMakeLists.txt
+++ b/src/plugins/qmltooling/qmldbg_debugger/CMakeLists.txt
@@ -20,6 +20,8 @@ qt_internal_add_plugin(QQmlDebuggerServiceFactoryPlugin
qv4debuggeragent.cpp qv4debuggeragent.h
qv4debugjob.cpp qv4debugjob.h
qv4debugservice.cpp qv4debugservice.h
+ NO_PCH_SOURCES
+ qv4debuggeragent.cpp # undef QT_NO_FOREACH
LIBRARIES
Qt::CorePrivate
Qt::PacketProtocolPrivate
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
index 11e1a49512..da84dbb2f9 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "qv4debuggeragent.h"
#include "qv4debugservice.h"
#include "qv4datacollector.h"
diff --git a/src/qmldebug/CMakeLists.txt b/src/qmldebug/CMakeLists.txt
index 084e90cc19..052c9bfd60 100644
--- a/src/qmldebug/CMakeLists.txt
+++ b/src/qmldebug/CMakeLists.txt
@@ -34,6 +34,8 @@ qt_internal_add_module(QmlDebugPrivate
qqmlprofilertypedevent.cpp qqmlprofilertypedevent_p.h
qv4debugclient.cpp qv4debugclient_p.h
qv4debugclient_p_p.h
+ NO_PCH_SOURCES
+ qv4debugclient.cpp # undef QT_NO_FOREACH
PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::Network
diff --git a/src/qmldebug/qv4debugclient.cpp b/src/qmldebug/qv4debugclient.cpp
index cb05a015a7..87f6a67d22 100644
--- a/src/qmldebug/qv4debugclient.cpp
+++ b/src/qmldebug/qv4debugclient.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "qv4debugclient_p.h"
#include "qv4debugclient_p_p.h"
#include "qqmldebugconnection_p.h"
diff --git a/src/qmldom/CMakeLists.txt b/src/qmldom/CMakeLists.txt
index 34058423bf..30d94d2368 100644
--- a/src/qmldom/CMakeLists.txt
+++ b/src/qmldom/CMakeLists.txt
@@ -41,6 +41,8 @@ qt_internal_add_module(QmlDomPrivate
qqmldomtop.cpp qqmldomtop_p.h
qqmldomtypesreader.cpp qqmldomtypesreader_p.h
qqmldomscriptelements_p.h qqmldomscriptelements.cpp
+ NO_PCH_SOURCES
+ qqmldomcodeformatter.cpp # undef QT_NO_FOREACH
DEFINES
QMLDOM_LIBRARY
PUBLIC_LIBRARIES
diff --git a/src/qmldom/qqmldomcodeformatter.cpp b/src/qmldom/qqmldomcodeformatter.cpp
index 5660025fd8..dbe8e3a648 100644
--- a/src/qmldom/qqmldomcodeformatter.cpp
+++ b/src/qmldom/qqmldomcodeformatter.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "qqmldomcodeformatter_p.h"
#include <QLoggingCategory>
diff --git a/tests/auto/qml/debugger/qqmldebugclient/CMakeLists.txt b/tests/auto/qml/debugger/qqmldebugclient/CMakeLists.txt
index d0a63440da..b99a0ec95a 100644
--- a/tests/auto/qml/debugger/qqmldebugclient/CMakeLists.txt
+++ b/tests/auto/qml/debugger/qqmldebugclient/CMakeLists.txt
@@ -19,6 +19,8 @@ qt_internal_add_test(tst_qqmldebugclient
../shared/qqmldebugprocess.cpp ../shared/qqmldebugprocess_p.h
../shared/qqmldebugtestservice.cpp ../shared/qqmldebugtestservice.h
tst_qqmldebugclient.cpp
+ NO_PCH_SOURCES
+ tst_qqmldebugclient.cpp # undef QT_NO_FOREACH
DEFINES
QT_QML_DEBUG
QT_QML_DEBUG_NO_WARNING
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
index 509791b96d..c89e91be68 100644
--- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "debugutil_p.h"
#include "qqmldebugtestservice.h"
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/CMakeLists.txt b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/CMakeLists.txt
index 53b1e9c683..53ebdff40d 100644
--- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/CMakeLists.txt
+++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/CMakeLists.txt
@@ -18,6 +18,8 @@ qt_internal_add_test(tst_qqmldebuggingenabler
../../shared/debugutil.cpp ../../shared/debugutil_p.h
../../shared/qqmldebugprocess.cpp ../../shared/qqmldebugprocess_p.h
tst_qqmldebuggingenabler.cpp
+ NO_PCH_SOURCES
+ tst_qqmldebuggingenabler.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
../../shared
LIBRARIES
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
index ab599e9a23..19e3c7fa66 100644
--- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
+++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "debugutil_p.h"
#include "qqmldebugprocess_p.h"
#include <QtQuickTestUtils/private/qmlutils_p.h>
diff --git a/tests/auto/qml/debugger/qqmldebugservice/CMakeLists.txt b/tests/auto/qml/debugger/qqmldebugservice/CMakeLists.txt
index 2169cb8e0e..44ab5043f0 100644
--- a/tests/auto/qml/debugger/qqmldebugservice/CMakeLists.txt
+++ b/tests/auto/qml/debugger/qqmldebugservice/CMakeLists.txt
@@ -25,6 +25,8 @@ qt_internal_add_test(tst_qqmldebugservice
../shared/qqmldebugprocess.cpp ../shared/qqmldebugprocess_p.h
../shared/qqmldebugtestservice.cpp ../shared/qqmldebugtestservice.h
tst_qqmldebugservice.cpp
+ NO_PCH_SOURCES
+ tst_qqmldebugservice.cpp # undef QT_NO_FOREACH
DEFINES
QT_QML_DEBUG_NO_WARNING
INCLUDE_DIRECTORIES
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
index b63786d6f3..f5f830f307 100644
--- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "qqmldebugtestservice.h"
#include "debugutil_p.h"
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/CMakeLists.txt b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/CMakeLists.txt
index bb36f678c3..042f5736d8 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/CMakeLists.txt
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/CMakeLists.txt
@@ -24,6 +24,8 @@ qt_internal_add_test(tst_qqmlenginedebuginspectorintegration
../shared/debugutil.cpp ../shared/debugutil_p.h
../shared/qqmldebugprocess.cpp ../shared/qqmldebugprocess_p.h
tst_qqmlenginedebuginspectorintegration.cpp
+ NO_PCH_SOURCES
+ tst_qqmlenginedebuginspectorintegration.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
../shared
LIBRARIES
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
index 890f4eeef6..a33ef37545 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "../shared/debugutil_p.h"
#include <QtQuickTestUtils/private/qmlutils_p.h>
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/CMakeLists.txt b/tests/auto/qml/debugger/qqmlprofilerservice/CMakeLists.txt
index d770f1fb27..599be99c49 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/CMakeLists.txt
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/CMakeLists.txt
@@ -24,6 +24,8 @@ qt_internal_add_test(tst_qqmlprofilerservice
../shared/debugutil.cpp ../shared/debugutil_p.h
../shared/qqmldebugprocess.cpp ../shared/qqmldebugprocess_p.h
tst_qqmlprofilerservice.cpp
+ NO_PCH_SOURCES
+ tst_qqmlprofilerservice.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
../shared
LIBRARIES
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index 416f707595..699ff56dd9 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "debugutil_p.h"
#include "qqmldebugprocess_p.h"
#include <QtQuickTestUtils/private/qmlutils_p.h>
diff --git a/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt b/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt
index 42f6cf931a..9f982563b7 100644
--- a/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt
+++ b/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt
@@ -39,6 +39,8 @@ qt_internal_add_test(tst_qv4debugger
../../../../../src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp ../../../../../src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h
../../../../../src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp ../../../../../src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
tst_qv4debugger.cpp
+ NO_PCH_SOURCES
+ tst_qv4debugger.cpp
INCLUDE_DIRECTORIES
../../../../../src/plugins/qmltooling/qmldbg_debugger
LIBRARIES
diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
index f4118ae5c3..659881144d 100644
--- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtTest/QtTest>
diff --git a/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp b/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp
index 1aec5dcac3..8b36ed37e9 100644
--- a/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp
+++ b/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <qrandom.h>
#include <private/qqmlchangeset_p.h>
diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
index fa119136ff..5eaa8070fb 100644
--- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
+++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QObject>
#include <QQmlEngine>
diff --git a/tests/auto/qml/qqmlecmascript/CMakeLists.txt b/tests/auto/qml/qqmlecmascript/CMakeLists.txt
index 12cab47a36..8e52d026c0 100644
--- a/tests/auto/qml/qqmlecmascript/CMakeLists.txt
+++ b/tests/auto/qml/qqmlecmascript/CMakeLists.txt
@@ -23,6 +23,8 @@ qt_internal_add_test(tst_qqmlecmascript
SOURCES
testtypes.cpp testtypes.h
tst_qqmlecmascript.cpp
+ NO_PCH_SOURCES
+ testtypes.cpp # undef QT_NO_FOREACH
LIBRARIES
Qt::CorePrivate
Qt::Gui
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
index 85999ebc8b..9dbcd24fee 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.cpp
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "testtypes.h"
#ifndef QT_NO_WIDGETS
# include <QWidget>
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 2b8636e56d..e6a87bb51f 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QQmlEngine>
#include <QQmlContext>
#include <QNetworkAccessManager>
diff --git a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp
index b8e0b01f6d..0fb3666fcb 100644
--- a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp
+++ b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtCore>
#include <QtTest>
#include <QtQml>
diff --git a/tests/auto/qml/qqmllanguage/CMakeLists.txt b/tests/auto/qml/qqmllanguage/CMakeLists.txt
index cdab786a2f..2131d53c8c 100644
--- a/tests/auto/qml/qqmllanguage/CMakeLists.txt
+++ b/tests/auto/qml/qqmllanguage/CMakeLists.txt
@@ -23,6 +23,9 @@ qt_internal_add_test(tst_qqmllanguage
SOURCES
testtypes.cpp testtypes.h
tst_qqmllanguage.cpp
+ NO_PCH_SOURCES
+ testtypes.cpp # undef QT_NO_FOREACH
+ tst_qqmllanguage.cpp # undef QT_NO_FOREACH
LIBRARIES
Qt::CorePrivate
Qt::Gui
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 3c14d67bf4..26cbd4a96b 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include "testtypes.h"
#include <private/qv4qmlcontext_p.h>
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index fbc09f35e0..22de19d2b4 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
diff --git a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp
index 2d02cac9f8..fd6b29159f 100644
--- a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp
+++ b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <private/qqmllistcompositor_p.h>
diff --git a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp
index a371b15b8b..65962ded7c 100644
--- a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp
+++ b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquicktext_p.h>
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index d9f65744ad..40c7973b06 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <qdir.h>
#include <QtQml/qqmlengine.h>
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index adad96b864..f419c54ee2 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <private/qqmljsengine_p.h>
#include <private/qqmljsparser_p.h>
#include <private/qqmljslexer_p.h>
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index a4692de826..a36a4fa744 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <private/qqmlengine_p.h>
#include <qtest.h>
diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
index 67c44684a4..8c6b4ee835 100644
--- a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
+++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
diff --git a/tests/auto/qml/qqmlvaluetypes/CMakeLists.txt b/tests/auto/qml/qqmlvaluetypes/CMakeLists.txt
index e167aade13..a9c6714f36 100644
--- a/tests/auto/qml/qqmlvaluetypes/CMakeLists.txt
+++ b/tests/auto/qml/qqmlvaluetypes/CMakeLists.txt
@@ -23,6 +23,8 @@ qt_internal_add_test(tst_qqmlvaluetypes
SOURCES
testtypes.cpp testtypes.h
tst_qqmlvaluetypes.cpp
+ NO_PCH_SOURCES
+ tst_qqmlvaluetypes.cpp # undef QT_NO_FOREACH
LIBRARIES
Qt::CorePrivate
Qt::Gui
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 1f9dfb7fd4..65a2bc7323 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QQmlEngine>
#include <QQmlComponent>
diff --git a/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp b/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp
index cc24e900ad..7363e61b29 100644
--- a/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp
+++ b/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtTest/QtTest>
#include <QQmlEngine>
#include <QtQml>
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index 3d4bc51d66..fa10b2cd39 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QLibraryInfo>
#include <QDir>
diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
index b7c0d28637..e52e215bad 100644
--- a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
+++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QSignalSpy>
#include <private/qquickitem_p.h>
diff --git a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
index c35f31b8f2..9269a24c50 100644
--- a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
+++ b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 9e42e0f4e4..9c19dcf26e 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtTest/QtTest>
#include <QtCore/qstringlistmodel.h>
#include <QtQuick/qquickview.h>
diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
index 78727d32a0..1f522b703e 100644
--- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
+++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QtTest/QtTest>
#include <QtQml/qqmlengine.h>
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 95c79a0d81..ec7c9b40d0 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QtTest/QSignalSpy>
#include <QtQml/qqmlengine.h>
diff --git a/tests/auto/quick/qquicklistview/CMakeLists.txt b/tests/auto/quick/qquicklistview/CMakeLists.txt
index cee287ae41..e621fb01d1 100644
--- a/tests/auto/quick/qquicklistview/CMakeLists.txt
+++ b/tests/auto/quick/qquicklistview/CMakeLists.txt
@@ -26,6 +26,8 @@ qt_internal_add_test(tst_qquicklistview
randomsortmodel.cpp randomsortmodel.h
reusemodel.h
tst_qquicklistview.cpp
+ NO_PCH_SOURCES
+ tst_qquicklistview.cpp # undef QT_NO_FOREACH
LIBRARIES
Qt::CorePrivate
Qt::Gui
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 4d3a8b1447..9ef91ed3a9 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtTest/QtTest>
#include <QtCore/QStringListModel>
#include <QtCore/QSortFilterProxyModel>
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index 7e9aa8c100..b76d4e4312 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QSignalSpy>
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 98085002ea..fb0b1d2f7a 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtTest/QtTest>
#include <QtQuick/qquickview.h>
#include <QtQml/qqmlengine.h>
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 317694f06c..6f572d16a8 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtTest/QtTest>
#include <QtQuick/qquickview.h>
#include <qqmlengine.h>
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 9a3c6efba3..0adb3fc8a0 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#include <QtTest/QSignalSpy>
#include <QtQuickTestUtils/private/qmlutils_p.h>
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index 23ff181ea4..39a45f0f4c 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -1,5 +1,8 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
#include <QtQuickTestUtils/private/viewtestutils_p.h>
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index 89a853bf5c..d40b2b3ad3 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtest.h>
#if QT_CONFIG(opengl)