Skip to content

[Many pragma] Removing last remnants of pragma block at the top of pybind11.h #3168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/pybind11/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

#include "cast.h"

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

/// \addtogroup annotations
Expand Down Expand Up @@ -562,3 +567,7 @@ constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {

PYBIND11_NAMESPACE_END(detail)
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif
23 changes: 20 additions & 3 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
# elif __INTEL_COMPILER < 1900 && defined(PYBIND11_CPP14)
# error pybind11 supports only C++11 with Intel C++ compiler v18. Use v19 or newer for C++14.
# endif
/* The following pragma cannot be pop'ed:
https://community.intel.com/t5/Intel-C-Compiler/Inline-and-no-inline-warning/td-p/1216764 */
# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
#elif defined(__clang__) && !defined(__apple_build_version__)
# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 3)
# error pybind11 requires clang 3.3 or newer
Expand Down Expand Up @@ -110,6 +107,17 @@
# define PYBIND11_NOINLINE __attribute__ ((noinline)) inline
#endif

#if !defined(PYBIND11_NOINLINE_DISABLED)
# if (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8))) \
&& !defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# define PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED
# elif defined(__INTEL_COMPILER)
// The following pragma cannot be pop'ed:
// https://community.intel.com/t5/Intel-C-Compiler/Inline-and-no-inline-warning/td-p/1216764
# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
# endif
#endif

#if defined(__MINGW32__)
// For unknown reasons all PYBIND11_DEPRECATED member trigger a warning when declared
// whether it is used or not
Expand Down Expand Up @@ -379,6 +387,11 @@ extern "C" {
} \
void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

using ssize_t = Py_ssize_t;
Expand Down Expand Up @@ -965,3 +978,7 @@ constexpr inline bool silence_msvc_c4127(bool cond) { return cond; }

PYBIND11_NAMESPACE_END(detail)
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif
9 changes: 9 additions & 0 deletions include/pybind11/detail/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

#include "../pytypes.h"

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

using ExceptionTranslator = void (*)(std::exception_ptr);
Expand Down Expand Up @@ -380,3 +385,7 @@ T &get_or_create_shared_data(const std::string &name) {
}

PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif
9 changes: 9 additions & 0 deletions include/pybind11/detail/type_caster_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include <utility>
#include <vector>

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
PYBIND11_NAMESPACE_BEGIN(detail)

Expand Down Expand Up @@ -949,3 +954,7 @@ template <typename type> class type_caster_base : public type_caster_generic {

PYBIND11_NAMESPACE_END(detail)
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif
9 changes: 9 additions & 0 deletions include/pybind11/detail/typeid.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

#include "common.h"

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
PYBIND11_NAMESPACE_BEGIN(detail)
/// Erase all occurrences of a substring
Expand Down Expand Up @@ -53,3 +58,7 @@ template <typename T> static std::string type_id() {
}

PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif
10 changes: 9 additions & 1 deletion include/pybind11/gil.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
#include "detail/common.h"
#include "detail/internals.h"

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

PYBIND11_NAMESPACE_BEGIN(detail)

Expand Down Expand Up @@ -191,3 +195,7 @@ class gil_scoped_release {
#endif

PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif
9 changes: 9 additions & 0 deletions include/pybind11/numpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
#endif

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

/* This will be true on all flat address space platforms and allows us to reduce the
whole npy_intp / ssize_t / Py_intptr_t business down to just ssize_t for all size
and dimension types (e.g. shape, strides, indexing), instead of inflicting this
Expand Down Expand Up @@ -1709,6 +1714,10 @@ Helper vectorize(Return (Class::*f)(Args...) const) {

PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif

#if defined(_MSC_VER)
#pragma warning(pop)
#endif
19 changes: 9 additions & 10 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

#pragma once

#if defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

#include "attr.h"
#include "gil.h"
#include "options.h"
Expand Down Expand Up @@ -52,6 +47,11 @@
# pragma GCC diagnostic ignored "-Wnoexcept-type"
#endif

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

PYBIND11_NAMESPACE_BEGIN(detail)
Expand Down Expand Up @@ -1874,7 +1874,6 @@ template <typename Type> class enum_ : public class_<Type> {

PYBIND11_NAMESPACE_BEGIN(detail)


PYBIND11_NOINLINE void keep_alive_impl(handle nurse, handle patient) {
if (!nurse || !patient)
pybind11_fail("Could not activate keep_alive!");
Expand Down Expand Up @@ -2380,10 +2379,10 @@ inline function get_overload(const T *this_ptr, const char *name) {

PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(__GNUC__) && __GNUC__ == 7
# pragma GCC diagnostic pop // -Wnoexcept-type
#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif

#if defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8))
# pragma GCC diagnostic pop
#if defined(__GNUC__) && __GNUC__ == 7
# pragma GCC diagnostic pop // -Wnoexcept-type
#endif
9 changes: 9 additions & 0 deletions include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#include <utility>
#include <type_traits>

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

/* A few forward declarations */
Expand Down Expand Up @@ -1763,3 +1768,7 @@ PYBIND11_MATH_OPERATOR_BINARY(operator>>=, PyNumber_InPlaceRshift)

PYBIND11_NAMESPACE_END(detail)
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED)
# pragma GCC diagnostic pop
#endif