From 93a7ba2a7363300566c8db14c2ceff12c3ec0427 Mon Sep 17 00:00:00 2001 From: toh Date: Mon, 3 May 2021 14:02:51 +0200 Subject: [PATCH] Enable compiling with clang's -Wsuggest-override When compiling step definitions with clang's `-Wsuggest-override`, clang warns about every step definition because the expanded `body()` from the macro overrides a virtual function, but isn't marked `override`. --- include/cucumber-cpp/internal/RegistrationMacros.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/cucumber-cpp/internal/RegistrationMacros.hpp b/include/cucumber-cpp/internal/RegistrationMacros.hpp index 548e814e..676891dc 100644 --- a/include/cucumber-cpp/internal/RegistrationMacros.hpp +++ b/include/cucumber-cpp/internal/RegistrationMacros.hpp @@ -1,6 +1,12 @@ #ifndef CUKE_REGISTRATIONMACROS_HPP_ #define CUKE_REGISTRATIONMACROS_HPP_ +#if __cplusplus >= 201103L +#define CUKE_OVERRIDE override +#else +#define CUKE_OVERRIDE +#endif + // ************************************************************************** // // ************** OBJECT NAMING MACROS ************** // // ************************************************************************** // @@ -24,7 +30,7 @@ #define CUKE_OBJECT_(class_name, parent_class, registration_fn, args) \ class class_name : public parent_class { \ public: \ - void body() { \ + void body() CUKE_OVERRIDE { \ return invokeWithArgs(*this, &class_name::bodyWithArgs); \ } \ void bodyWithArgs args; \