From fc92d82bba9d8b9d87cc1a83241e7b4693f79b39 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2016 23:55:44 +0200 Subject: [PATCH] added [[noreturn]] attribute to pybind11_fail --- example/example12.cpp | 1 - include/pybind11/common.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/example/example12.cpp b/example/example12.cpp index 84b1c3585..5d32eed19 100644 --- a/example/example12.cpp +++ b/example/example12.cpp @@ -56,7 +56,6 @@ public: /* This function has no arguments. The trailing comma in the previous line is needed for some compilers */ ); - throw std::runtime_error("this will never be reached"); } virtual void pure_virtual() { diff --git a/include/pybind11/common.h b/include/pybind11/common.h index a719a4dbd..37238f966 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -324,7 +324,7 @@ struct error_already_set : public std::runtime_error { public: error_already_set /// Thrown when pybind11::cast or handle::call fail due to a type casting error struct cast_error : public std::runtime_error { public: cast_error(const std::string &w = "") : std::runtime_error(w) {} }; -PYBIND11_NOINLINE inline void pybind11_fail(const char *reason) { throw std::runtime_error(reason); } -PYBIND11_NOINLINE inline void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); } +[[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const char *reason) { throw std::runtime_error(reason); } +[[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); } NAMESPACE_END(pybind11)