Commit af24a5bf authored by Dominik Charousset's avatar Dominik Charousset

Fix warnings on GCC 11

parent 1855e8e0
...@@ -38,15 +38,13 @@ constexpr actor_id invalid_actor_id = 0; ...@@ -38,15 +38,13 @@ constexpr actor_id invalid_actor_id = 0;
/// Base class for all actor implementations. /// Base class for all actor implementations.
class CAF_CORE_EXPORT abstract_actor : public abstract_channel { class CAF_CORE_EXPORT abstract_actor : public abstract_channel {
public: public:
// allow placement new (only)
void* operator new(std::size_t, void* ptr) {
return ptr;
}
actor_control_block* ctrl() const; actor_control_block* ctrl() const;
~abstract_actor() override; ~abstract_actor() override;
abstract_actor(const abstract_actor&) = delete;
abstract_actor& operator=(const abstract_actor&) = delete;
/// Cleans up any remaining state before the destructor is called. /// Cleans up any remaining state before the destructor is called.
/// This function makes sure it is safe to call virtual functions /// This function makes sure it is safe to call virtual functions
/// in sub classes before destroying the object, because calling /// in sub classes before destroying the object, because calling
...@@ -199,19 +197,11 @@ public: ...@@ -199,19 +197,11 @@ public:
/// @endcond /// @endcond
protected: protected:
/// Creates a new actor instance.
explicit abstract_actor(actor_config& cfg); explicit abstract_actor(actor_config& cfg);
// Guards potentially concurrent access to the state. For example, // Guards potentially concurrent access to the state. For example,
// `exit_state_`, `attachables_`, and `links_` in a `monitorable_actor`. // `exit_state_`, `attachables_`, and `links_` in a `monitorable_actor`.
mutable std::mutex mtx_; mutable std::mutex mtx_;
private:
// prohibit copies, assignments, and heap allocations
void* operator new(size_t);
void* operator new[](size_t);
abstract_actor(const abstract_actor&) = delete;
abstract_actor& operator=(const abstract_actor&) = delete;
}; };
} // namespace caf } // namespace caf
...@@ -287,7 +287,7 @@ bool inspect(Inspector& f, dummy_enum& x) { ...@@ -287,7 +287,7 @@ bool inspect(Inspector& f, dummy_enum& x) {
using integer_type = std::underlying_type_t<dummy_enum>; using integer_type = std::underlying_type_t<dummy_enum>;
auto get = [&x] { return static_cast<integer_type>(x); }; auto get = [&x] { return static_cast<integer_type>(x); };
auto set = [&x](integer_type val) { auto set = [&x](integer_type val) {
if (val >= 0 && val <= 1) { if (val <= 1) {
x = static_cast<dummy_enum>(val); x = static_cast<dummy_enum>(val);
return true; return true;
} else { } else {
......
...@@ -55,6 +55,7 @@ SCENARIO("monotonic buffers group allocations") { ...@@ -55,6 +55,7 @@ SCENARIO("monotonic buffers group allocations") {
CHECK_EQ(mbr.blocks(), 4u); CHECK_EQ(mbr.blocks(), 4u);
unused = mbr.allocate(1'048'577); unused = mbr.allocate(1'048'577);
CHECK_EQ(mbr.blocks(), 5u); CHECK_EQ(mbr.blocks(), 5u);
static_cast<void>(unused);
} }
} }
} }
......
...@@ -11,12 +11,11 @@ ...@@ -11,12 +11,11 @@
using namespace caf; using namespace caf;
#define ASSERT_COMPILES(expr, msg) \ #define ASSERT_COMPILES(expr, msg) \
static_assert(std::is_void_v<decltype(expr)>, msg); static_assert( \
std::is_void_v<decltype(std::declval<scheduled_actor*>()->expr)>, msg);
namespace { namespace {
constexpr scheduled_actor* nil_actor = nullptr;
// -- compile-time checks for set_default_handler ------------------------------ // -- compile-time checks for set_default_handler ------------------------------
struct mutable_default_fn { struct mutable_default_fn {
...@@ -25,7 +24,7 @@ struct mutable_default_fn { ...@@ -25,7 +24,7 @@ struct mutable_default_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_default_handler(mutable_default_fn{}), ASSERT_COMPILES(set_default_handler(mutable_default_fn{}),
"set_default_handler must accept mutable function objects"); "set_default_handler must accept mutable function objects");
struct const_default_fn { struct const_default_fn {
...@@ -34,7 +33,7 @@ struct const_default_fn { ...@@ -34,7 +33,7 @@ struct const_default_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_default_handler(const_default_fn{}), ASSERT_COMPILES(set_default_handler(const_default_fn{}),
"set_default_handler must accept const function objects"); "set_default_handler must accept const function objects");
// -- compile-time checks for set_error_handler -------------------------------- // -- compile-time checks for set_error_handler --------------------------------
...@@ -45,7 +44,7 @@ struct mutable_error_fn { ...@@ -45,7 +44,7 @@ struct mutable_error_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_error_handler(mutable_error_fn{}), ASSERT_COMPILES(set_error_handler(mutable_error_fn{}),
"set_error_handler must accept mutable function objects"); "set_error_handler must accept mutable function objects");
struct const_error_fn { struct const_error_fn {
...@@ -54,7 +53,7 @@ struct const_error_fn { ...@@ -54,7 +53,7 @@ struct const_error_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_error_handler(const_error_fn{}), ASSERT_COMPILES(set_error_handler(const_error_fn{}),
"set_error_handler must accept const function objects"); "set_error_handler must accept const function objects");
// -- compile-time checks for set_down_handler --------------------------------- // -- compile-time checks for set_down_handler ---------------------------------
...@@ -65,7 +64,7 @@ struct mutable_down_fn { ...@@ -65,7 +64,7 @@ struct mutable_down_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_down_handler(mutable_down_fn{}), ASSERT_COMPILES(set_down_handler(mutable_down_fn{}),
"set_down_handler must accept mutable function objects"); "set_down_handler must accept mutable function objects");
struct const_down_fn { struct const_down_fn {
...@@ -74,7 +73,7 @@ struct const_down_fn { ...@@ -74,7 +73,7 @@ struct const_down_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_down_handler(const_down_fn{}), ASSERT_COMPILES(set_down_handler(const_down_fn{}),
"set_down_handler must accept const function objects"); "set_down_handler must accept const function objects");
// -- compile-time checks for set_node_down_handler ---------------------------- // -- compile-time checks for set_node_down_handler ----------------------------
...@@ -85,7 +84,7 @@ struct mutable_node_down_fn { ...@@ -85,7 +84,7 @@ struct mutable_node_down_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_node_down_handler(mutable_node_down_fn{}), ASSERT_COMPILES(set_node_down_handler(mutable_node_down_fn{}),
"set_node_down_handler must accept mutable function objects"); "set_node_down_handler must accept mutable function objects");
struct const_node_down_fn { struct const_node_down_fn {
...@@ -94,7 +93,7 @@ struct const_node_down_fn { ...@@ -94,7 +93,7 @@ struct const_node_down_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_node_down_handler(const_node_down_fn{}), ASSERT_COMPILES(set_node_down_handler(const_node_down_fn{}),
"set_node_down_handler must accept const function objects"); "set_node_down_handler must accept const function objects");
// -- compile-time checks for set_exit_handler --------------------------------- // -- compile-time checks for set_exit_handler ---------------------------------
...@@ -105,7 +104,7 @@ struct mutable_exit_fn { ...@@ -105,7 +104,7 @@ struct mutable_exit_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_exit_handler(mutable_exit_fn{}), ASSERT_COMPILES(set_exit_handler(mutable_exit_fn{}),
"set_exit_handler must accept mutable function objects"); "set_exit_handler must accept mutable function objects");
struct const_exit_fn { struct const_exit_fn {
...@@ -114,7 +113,7 @@ struct const_exit_fn { ...@@ -114,7 +113,7 @@ struct const_exit_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_exit_handler(const_exit_fn{}), ASSERT_COMPILES(set_exit_handler(const_exit_fn{}),
"set_exit_handler must accept const function objects"); "set_exit_handler must accept const function objects");
// -- compile-time checks for set_exception_handler ---------------------------- // -- compile-time checks for set_exception_handler ----------------------------
...@@ -127,7 +126,7 @@ struct mutable_exception_fn { ...@@ -127,7 +126,7 @@ struct mutable_exception_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_exception_handler(mutable_exception_fn{}), ASSERT_COMPILES(set_exception_handler(mutable_exception_fn{}),
"set_exception_handler must accept mutable function objects"); "set_exception_handler must accept mutable function objects");
struct const_exception_fn { struct const_exception_fn {
...@@ -136,7 +135,7 @@ struct const_exception_fn { ...@@ -136,7 +135,7 @@ struct const_exception_fn {
} }
}; };
ASSERT_COMPILES(nil_actor->set_exception_handler(const_exception_fn{}), ASSERT_COMPILES(set_exception_handler(const_exception_fn{}),
"set_exception_handler must accept const function objects"); "set_exception_handler must accept const function objects");
#endif // CAF_ENABLE_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment