From 7277ffee522bdf57128d292b02d2b127f5038bee Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 4 Feb 2022 18:33:39 +0100 Subject: [PATCH] QCalendar: fix build Apple Clang 12: qcalendar.cpp:456:22: error: loop variable '[key, value]' is always a copy because the range of type 'QFlatMap >' (aka 'QFlatMap, vector >') does not return a reference [-Werror,-Wrange-loop-analysis] for (const auto &[key, value] : byName) { ^ Change-Id: I54f205f6b7314351b078fffd16d05e5cd3ef4c22 Reviewed-by: Qt CI Bot Reviewed-by: Marc Mutz Reviewed-by: Fabian Kosmale --- src/corelib/time/qcalendar.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp index a7f6a634d6..3d990b7f5d 100644 --- a/src/corelib/time/qcalendar.cpp +++ b/src/corelib/time/qcalendar.cpp @@ -453,10 +453,16 @@ QStringList QCalendarRegistry::backendNames(const QCalendarBackend *backend) QStringList l; l.reserve(byName.size()); // too large, but never really large, so ok + QT_WARNING_PUSH + // Clang complains about the reference still causing a copy. The reference is idiomatic, but + // runs afoul of QFlatMap's iterators which return a pair of references instead of a reference + // to pair. Suppress the warning, because `const auto [key, value]` would look wrong. + QT_WARNING_DISABLE_CLANG("-Wrange-loop-analysis") for (const auto &[key, value] : byName) { if (value == backend) l.push_back(key); } + QT_WARNING_POP return l; }