From 957ce6868ba2b869464f268c030f64ceb639dbda Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 7 Jan 2025 18:35:31 +0100 Subject: [PATCH] Silence qcompare.h "zero as null pointer constant" warnings on macOS When using qmake to build a user project on macOS, the Qt headers are included with the -I option, rather than the -isystem option. This means that the compiler will not silence warnings that are generated while parsing Qt headers. If the user project compiles their code with the -Wzero-as-null-pointer-constant compiler option, this leads to warnings like: /QtCore.framework/Headers/qcompare.h:226:78: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant] friend constexpr bool is_eq (partial_ordering o) noexcept { return o == 0; } ^ nullptr Fixing qmake to use -isystem instead of -I is not trivial. We already silence these warnings for gcc in the header file. Do it for clang as well. Amends bdd41f491c0f85ae0897a1c7372c5ecda62a5aab Fixes: QTBUG-132581 Change-Id: I7883248b7be548580a03333e76620ac10f57733a Reviewed-by: Thiago Macieira Reviewed-by: Ivan Solovev (cherry picked from commit 0711eb60716b53dc86cacb2fc19b72aa4ffee3d0) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit fa8effc7da2417f6ccaca923bd1b2c376f63ac38) --- src/corelib/global/qcompare.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/global/qcompare.h b/src/corelib/global/qcompare.h index 7fbf9aabcb..0966cdfe9e 100644 --- a/src/corelib/global/qcompare.h +++ b/src/corelib/global/qcompare.h @@ -223,6 +223,7 @@ private: QT_WARNING_PUSH // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100903 QT_WARNING_DISABLE_GCC("-Wzero-as-null-pointer-constant") + QT_WARNING_DISABLE_CLANG("-Wzero-as-null-pointer-constant") friend constexpr bool is_eq (partial_ordering o) noexcept { return o == 0; } friend constexpr bool is_neq (partial_ordering o) noexcept { return o != 0; } friend constexpr bool is_lt (partial_ordering o) noexcept { return o < 0; } @@ -408,6 +409,7 @@ private: QT_WARNING_PUSH // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100903 QT_WARNING_DISABLE_GCC("-Wzero-as-null-pointer-constant") + QT_WARNING_DISABLE_CLANG("-Wzero-as-null-pointer-constant") friend constexpr bool is_eq (weak_ordering o) noexcept { return o == 0; } friend constexpr bool is_neq (weak_ordering o) noexcept { return o != 0; } friend constexpr bool is_lt (weak_ordering o) noexcept { return o < 0; } @@ -603,6 +605,7 @@ public: QT_WARNING_PUSH // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100903 QT_WARNING_DISABLE_GCC("-Wzero-as-null-pointer-constant") + QT_WARNING_DISABLE_CLANG("-Wzero-as-null-pointer-constant") friend constexpr bool is_eq (strong_ordering o) noexcept { return o == 0; } friend constexpr bool is_neq (strong_ordering o) noexcept { return o != 0; } friend constexpr bool is_lt (strong_ordering o) noexcept { return o < 0; } @@ -852,6 +855,7 @@ private: QT_WARNING_PUSH // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100903 QT_WARNING_DISABLE_GCC("-Wzero-as-null-pointer-constant") + QT_WARNING_DISABLE_CLANG("-Wzero-as-null-pointer-constant") friend constexpr bool is_eq (QPartialOrdering o) noexcept { return o == 0; } friend constexpr bool is_neq (QPartialOrdering o) noexcept { return o != 0; } friend constexpr bool is_lt (QPartialOrdering o) noexcept { return o < 0; }