Silence dangling pointer warning for JS::Rooted

With much help by @sera.
This commit is contained in:
phosit 2025-01-05 08:58:11 +01:00 committed by phosit
parent 18d7746c84
commit 40fe7df654
3 changed files with 35 additions and 1 deletions

View file

@ -8,7 +8,7 @@ cd "$(dirname "$0")"
# This should match the version in config/milestone.txt
FOLDER="mozjs-115.16.1"
# If same-version changes are needed, increment this.
LIB_VERSION="115.16.1+4"
LIB_VERSION="115.16.1+5"
LIB_NAME="mozjs115"
fetch()

View file

@ -0,0 +1,31 @@
From 0bfc032c102b8a251e4dc751d0b48992ebf72641 Mon Sep 17 00:00:00 2001
From: phosit <phosit@autistici.org>
Date: Sun, 5 Jan 2025 14:29:33 +0100
Subject: [PATCH] Supress -Wdangling-pointer warning on GCC
---
js/public/RootingAPI.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h
index 42be14e67351..6b167cb8ea2e 100644
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -1166,7 +1166,14 @@ class MOZ_RAII Rooted : public detail::RootedTraits<T>::StackBase,
inline void registerWithRootLists(RootedListHeads& roots) {
this->stack = &roots[JS::MapTypeToRootKind<T>::kind];
this->prev = *this->stack;
+#if defined(__GNUC__) && __GNUC__ >= 12
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdangling-pointer"
+#endif
*this->stack = this;
+#if defined(__GNUC__) && __GNUC__ >= 12
+#pragma GCC diagnostic pop
+#endif
}
inline RootedListHeads& rootLists(RootingContext* cx) {
--
2.47.1

View file

@ -46,3 +46,6 @@ patch -p1 <"${PATCHES}"/FixPython3.12.8.diff
# https://bugzilla.mozilla.org/show_bug.cgi?id=1876415
# Fixed in ESR 128
patch -p1 <"${PATCHES}"/FixProfiling.diff
# Supress warning on newer GCC compilers.
patch -p1 <"${PATCHES}"/SupressDanglingPointerWarning.patch