From 3e2f5d615d3b89a2660fc108b83a266dd2eea820 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 23 Jan 2020 13:43:03 +0100 Subject: [PATCH] src: ignore GCC -Wcast-function-type for v8.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit suggests that cast-function-type warnings be ignored from v8.h. Currently, GCC reports a number of warnings like this: In file included from ../src/util.h:27, from ../src/aliased_buffer.h:7, from ../src/memory_tracker.h:5, from ../src/base_object.h:27, from ../src/async_wrap.h:27, from ../src/req_wrap.h:6, from ../src/req_wrap-inl.h:6, from ../src/connect_wrap.h:6, from ../src/connect_wrap.cc:1: ../deps/v8/include/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak( P*, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = node::BaseObject; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void (*)(const v8::WeakCallbackInfo&)]’: ../src/base_object-inl.h:123:42: required from here ../deps/v8/include/v8.h:10374:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} [-Wcast-function-type] reinterpret_cast(callback), type); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The motivation for doing this that it makes it difficult to spot other warnings that might be important. Since it is v8 that performs this cast I was not able to find a way around it. --- src/base_object-inl.h | 8 ++++++++ src/node.h | 7 +++++++ src/util.h | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/src/base_object-inl.h b/src/base_object-inl.h index f35cd6734edf0b..3d36eaa923012e 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -27,7 +27,15 @@ #include "base_object.h" #include "env-inl.h" #include "util.h" + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif #include "v8.h" +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif namespace node { diff --git a/src/node.h b/src/node.h index 00b0c0ea7e4541..b615ac8c2138d1 100644 --- a/src/node.h +++ b/src/node.h @@ -60,7 +60,14 @@ # define SIGKILL 9 #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif #include "v8.h" // NOLINT(build/include_order) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif #include "v8-platform.h" // NOLINT(build/include_order) #include "node_version.h" // NODE_MODULE_VERSION diff --git a/src/util.h b/src/util.h index 2f6c17fc321a67..94db8f79c8f166 100644 --- a/src/util.h +++ b/src/util.h @@ -24,7 +24,14 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif #include "v8.h" +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif #include #include // PATH_MAX