Skip to content

Commit 62976cf

Browse files
philbucherhenryiii
andauthored
fix: using -Werror-all for Intel (#2948)
* correcting Werror for Intel * adding ward for Intel * adding wards for intel * another ward for Intel * missed one intel ward * exact match for intel compiler * removing inline limits * disable warnings about inline limits * formatter suggestion * more indent * hopefully make formatter happy * addressed review * fix && * Update tests/CMakeLists.txt Co-authored-by: Henry Schreiner <[email protected]> Co-authored-by: Henry Schreiner <[email protected]>
1 parent 6709abb commit 62976cf

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

include/pybind11/pybind11.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ class cpp_function : public function {
143143
/* Without these pragmas, GCC warns that there might not be
144144
enough space to use the placement new operator. However, the
145145
'if' statement above ensures that this is the case. */
146-
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6
146+
#if defined(__GNUG__) && __GNUC__ >= 6 && !defined(__clang__) && !defined(__INTEL_COMPILER)
147147
# pragma GCC diagnostic push
148148
# pragma GCC diagnostic ignored "-Wplacement-new"
149149
#endif
150150
new ((capture *) &rec->data) capture { std::forward<Func>(f) };
151-
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6
151+
#if defined(__GNUG__) && __GNUC__ >= 6 && !defined(__clang__) && !defined(__INTEL_COMPILER)
152152
# pragma GCC diagnostic pop
153153
#endif
154154
if (!std::is_trivially_destructible<Func>::value)
@@ -2283,6 +2283,6 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
22832283

22842284
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
22852285
# pragma warning(pop)
2286-
#elif defined(__GNUG__) && !defined(__clang__)
2286+
#elif defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
22872287
# pragma GCC diagnostic pop
22882288
#endif

tests/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,15 @@ function(pybind11_enable_warnings target_name)
268268
target_compile_options(${target_name} PRIVATE /WX)
269269
elseif(PYBIND11_CUDA_TESTS)
270270
target_compile_options(${target_name} PRIVATE "SHELL:-Werror all-warnings")
271-
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)")
271+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang|IntelLLVM)")
272272
target_compile_options(${target_name} PRIVATE -Werror)
273+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
274+
target_compile_options(
275+
${target_name}
276+
PRIVATE
277+
-Werror-all
278+
# "Inlining inhibited by limit max-size", "Inlining inhibited by limit max-total-size"
279+
-diag-disable 11074,11076)
273280
endif()
274281
endif()
275282

tests/test_constants_and_functions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ int f1(int x) noexcept { return x+1; }
5656
#endif
5757
int f2(int x) noexcept(true) { return x+2; }
5858
int f3(int x) noexcept(false) { return x+3; }
59-
#if defined(__GNUG__)
59+
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
6060
# pragma GCC diagnostic push
6161
# pragma GCC diagnostic ignored "-Wdeprecated"
6262
#endif
6363
int f4(int x) throw() { return x+4; } // Deprecated equivalent to noexcept(true)
64-
#if defined(__GNUG__)
64+
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
6565
# pragma GCC diagnostic pop
6666
#endif
6767
struct C {
@@ -71,13 +71,13 @@ struct C {
7171
int m4(int x) const noexcept(true) { return x-4; }
7272
int m5(int x) noexcept(false) { return x-5; }
7373
int m6(int x) const noexcept(false) { return x-6; }
74-
#if defined(__GNUG__)
74+
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
7575
# pragma GCC diagnostic push
7676
# pragma GCC diagnostic ignored "-Wdeprecated"
7777
#endif
7878
int m7(int x) throw() { return x-7; }
7979
int m8(int x) const throw() { return x-8; }
80-
#if defined(__GNUG__)
80+
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
8181
# pragma GCC diagnostic pop
8282
#endif
8383
};

tests/test_operator_overloading.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ std::string abs(const Vector2&) {
8080
return "abs(Vector2)";
8181
}
8282

83-
// MSVC warns about unknown pragmas, and warnings are errors.
84-
#ifndef _MSC_VER
83+
// MSVC & Intel warns about unknown pragmas, and warnings are errors.
84+
#if !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
8585
#pragma GCC diagnostic push
8686
// clang 7.0.0 and Apple LLVM 10.0.1 introduce `-Wself-assign-overloaded` to
8787
// `-Wall`, which is used here for overloading (e.g. `py::self += py::self `).
@@ -221,6 +221,6 @@ TEST_SUBMODULE(operators, m) {
221221
.def(py::self == py::self);
222222
}
223223

224-
#ifndef _MSC_VER
224+
#if !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
225225
#pragma GCC diagnostic pop
226226
#endif

0 commit comments

Comments
 (0)