From 7edbd580cfad509a3253c733e70144e36f02ecd4 Mon Sep 17 00:00:00 2001
From: Axel Menzel <info@axelmenzel.de>
Date: Sun, 8 Aug 2021 12:27:15 +0200
Subject: [PATCH] add github actions workflow & disable gcc9 warnings
Additional: disable initializer list warning
---
.github/workflows/linux.yml | 23 +++++++++++++++++++
src/rttr/detail/base/core_prerequisites.h | 15 ++++++++++++
src/rttr/detail/variant/variant_data_policy.h | 3 ++-
3 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 .github/workflows/linux.yml
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
new file mode 100644
index 00000000..c232943e
--- /dev/null
+++ b/.github/workflows/linux.yml
@@ -0,0 +1,23 @@
+name: Linux
+
+on: [push]
+env:
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
+ BUILD_TYPE: Release
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: seanmiddleditch/gha-setup-ninja@master
+
+ - name: Configure CMake
+ run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_EXAMPLES=OFF -G Ninja
+
+ - name: Build
+ run: cmake --build ${{github.workspace}}/build
+
+ - name: Test
+ run: cmake --build ${{github.workspace}}/build --target run_tests
diff --git a/src/rttr/detail/base/core_prerequisites.h b/src/rttr/detail/base/core_prerequisites.h
index 6aa29d77..601ddeb9 100644
--- a/src/rttr/detail/base/core_prerequisites.h
+++ b/src/rttr/detail/base/core_prerequisites.h
@@ -278,6 +278,15 @@ namespace rttr
# define RTTR_END_DISABLE_OVERRIDE_WARNING
#endif
+#if RTTR_COMP_VER >= 900
+# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Winit-list-lifetime\"")
+# define RTTR_END_DISABLE_INIT_LIST_WARNING _Pragma ("GCC diagnostic pop")
+# else
+# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
+# define RTTR_END_DISABLE_INIT_LIST_WARNING
+#endif
+
# define RTTR_DECLARE_PLUGIN_CTOR __attribute__((constructor))
# define RTTR_DECLARE_PLUGIN_DTOR __attribute__((destructor))
@@ -313,6 +322,10 @@ namespace rttr
# define RTTR_END_DISABLE_OVERRIDE_WARNING
#endif
+
+# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
+# define RTTR_END_DISABLE_INIT_LIST_WARNING
+
# define RTTR_DECLARE_PLUGIN_CTOR __attribute__((__constructor__))
# define RTTR_DECLARE_PLUGIN_DTOR __attribute__((__destructor__))
@@ -332,6 +345,8 @@ namespace rttr
# define RTTR_DECLARE_PLUGIN_DTOR
# define RTTR_BEGIN_DISABLE_OVERRIDE_WARNING
# define RTTR_END_DISABLE_OVERRIDE_WARNING
+# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
+# define RTTR_END_DISABLE_INIT_LIST_WARNING
#else
# pragma message("WARNING: unknown compiler, don't know how to disable deprecated warnings")
diff --git a/src/rttr/detail/variant/variant_data_policy.h b/src/rttr/detail/variant/variant_data_policy.h
index 39dbb2f9..8eeaafbe 100644
--- a/src/rttr/detail/variant/variant_data_policy.h
+++ b/src/rttr/detail/variant/variant_data_policy.h
@@ -434,7 +434,7 @@ struct variant_data_policy_big : variant_data_base_policy<T, variant_data_policy
{
delete &value;
}
-
+RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
static RTTR_INLINE void clone(const T& value, variant_data& dest)
{
reinterpret_cast<T*&>(dest) = new T(value);
@@ -450,6 +450,7 @@ struct variant_data_policy_big : variant_data_base_policy<T, variant_data_policy
{
reinterpret_cast<T*&>(dest) = new T(std::forward<U>(value));
}
+RTTR_END_DISABLE_INIT_LIST_WARNING
};
/////////////////////////////////////////////////////////////////////////////////////////