Skip to content

Commit

Permalink
src: ignore GCC -Wcast-function-type for v8.h
Browse files Browse the repository at this point in the history
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<T>::SetWeak(
    P*,
    typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType)
[with
P = node::BaseObject;
T = v8::Object;
typename v8::WeakCallbackInfo<P>::Callback =
    void (*)(const v8::WeakCallbackInfo<node::BaseObject>&)]’:

../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<node::BaseObject>::Callback’
{aka ‘void (*)(const v8::WeakCallbackInfo<node::BaseObject>&)’} to
‘Callback’
{aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’}
[-Wcast-function-type]
                reinterpret_cast<Callback>(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.

PR-URL: #31475
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
danbev authored and codebytere committed Feb 17, 2020
1 parent f8f8e83 commit 13c6965
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
7 changes: 7 additions & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cassert>
#include <climits> // PATH_MAX
Expand Down

0 comments on commit 13c6965

Please sign in to comment.