From 1ffce7422d0848c4b8a6a6cdb0a9b8f02311f272 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 25 Aug 2016 01:43:33 +0200 Subject: [PATCH] Get pybind11 test suite to compile on the Intel compiler (more or less..) - ICPC can't handle the NCVirt trampoline which returns a non-copyable type, which is likely due to a constexpr/SFINAE issue. This disables the test on that compiler so that at least the rest can be tested. --- include/pybind11/pybind11.h | 14 ++++++++------ tests/pybind11_tests.cpp | 3 +-- tests/test_virtual_functions.cpp | 15 +++++++++------ tests/test_virtual_functions.py | 3 ++- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index d82ae926e..675827de2 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -12,14 +12,16 @@ #if defined(_MSC_VER) # pragma warning(push) +# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter # pragma warning(disable: 4127) // warning C4127: Conditional expression is constant +# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted # pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) # pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name -# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter -# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted -#elif defined(__ICC) || defined(__INTEL_COMPILER) +#elif defined(__INTEL_COMPILER) # pragma warning(push) -# pragma warning(disable:2196) // warning #2196: routine is both "inline" and "noinline" +# pragma warning(disable: 186) // pointless comparison of unsigned integer with zero +# pragma warning(disable: 1334) // the "template" keyword used for syntactic disambiguation may only be used within a template +# pragma warning(disable: 2196) // warning #2196: routine is both "inline" and "noinline" #elif defined(__GNUG__) && !defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-but-set-parameter" @@ -1414,8 +1416,8 @@ NAMESPACE_END(pybind11) #if defined(_MSC_VER) # pragma warning(pop) -#elif defined(__ICC) || defined(__INTEL_COMPILER) -# pragma warning(pop) +#elif defined(__INTEL_COMPILER) +/* Leave ignored warnings on */ #elif defined(__GNUG__) && !defined(__clang__) # pragma GCC diagnostic pop #endif diff --git a/tests/pybind11_tests.cpp b/tests/pybind11_tests.cpp index 80ecf0fb0..525f379eb 100644 --- a/tests/pybind11_tests.cpp +++ b/tests/pybind11_tests.cpp @@ -46,8 +46,7 @@ void bind_ConstructorStats(py::module &m) { .def_readwrite("move_assignments", &ConstructorStats::move_assignments) .def_readwrite("copy_constructions", &ConstructorStats::copy_constructions) .def_readwrite("move_constructions", &ConstructorStats::move_constructions) - .def_static("get", (ConstructorStats &(*)(py::object)) &ConstructorStats::get, py::return_value_policy::reference_internal) - ; + .def_static("get", (ConstructorStats &(*)(py::object)) &ConstructorStats::get, py::return_value_policy::reference_internal); } PYBIND11_PLUGIN(pybind11_tests) { diff --git a/tests/test_virtual_functions.cpp b/tests/test_virtual_functions.cpp index 1e2f0edd7..8926292b8 100644 --- a/tests/test_virtual_functions.cpp +++ b/tests/test_virtual_functions.cpp @@ -106,9 +106,11 @@ public: std::string print_movable(int a, int b) { return get_movable(a, b).get_value(); } }; class NCVirtTrampoline : public NCVirt { +#if !defined(__INTEL_COMPILER) virtual NonCopyable get_noncopyable(int a, int b) { PYBIND11_OVERLOAD(NonCopyable, NCVirt, get_noncopyable, a, b); } +#endif virtual Movable get_movable(int a, int b) { PYBIND11_OVERLOAD_PURE(Movable, NCVirt, get_movable, a, b); } @@ -288,18 +290,19 @@ void init_ex_virtual_functions(py::module &m) { .def("pure_virtual", &ExampleVirt::pure_virtual); py::class_(m, "NonCopyable") - .def(py::init()) - ; + .def(py::init()); + py::class_(m, "Movable") - .def(py::init()) - ; + .def(py::init()); + +#if !defined(__INTEL_COMPILER) py::class_, NCVirtTrampoline>(m, "NCVirt") .def(py::init<>()) .def("get_noncopyable", &NCVirt::get_noncopyable) .def("get_movable", &NCVirt::get_movable) .def("print_nc", &NCVirt::print_nc) - .def("print_movable", &NCVirt::print_movable) - ; + .def("print_movable", &NCVirt::print_movable); +#endif m.def("runExampleVirt", &runExampleVirt); m.def("runExampleVirtBool", &runExampleVirtBool); diff --git a/tests/test_virtual_functions.py b/tests/test_virtual_functions.py index 1388b1ae2..4d247502d 100644 --- a/tests/test_virtual_functions.py +++ b/tests/test_virtual_functions.py @@ -1,4 +1,5 @@ import pytest +import pybind11_tests from pybind11_tests import ConstructorStats @@ -150,7 +151,7 @@ def test_inheriting_repeat(): assert obj.unlucky_number() == 1234 assert obj.lucky_number() == -4.25 - +@pytest.mark.skipif(not hasattr(pybind11_tests, 'NCVirt')) def test_move_support(): from pybind11_tests import NCVirt, NonCopyable, Movable