From f698f33ca03e9ecfc14980cb8b7a5b3ca3b27219 Mon Sep 17 00:00:00 2001 From: Furkan Usta Date: Mon, 4 Sep 2017 13:17:00 +0300 Subject: [PATCH 1/3] Workaround for #416 Instead of adding std::fallthrough, this one disables implicit-fallthrough warnings via pragma push/pop mechanism --- include/cereal/archives/json.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/cereal/archives/json.hpp b/include/cereal/archives/json.hpp index 60fca1961..2b17cf7a8 100644 --- a/include/cereal/archives/json.hpp +++ b/include/cereal/archives/json.hpp @@ -68,6 +68,11 @@ namespace cereal #include #include +#if defined(__clang__) or (defined(__GNUC__) and __GNUC__ >= 7) +CEREAL_RAPIDJSON_DIAG_PUSH +CEREAL_RAPIDJSON_DIAG_OFF(implicit-fallthrough) +#endif + namespace cereal { // ###################################################################### @@ -1009,4 +1014,8 @@ CEREAL_REGISTER_ARCHIVE(cereal::JSONOutputArchive) // tie input and output archives together CEREAL_SETUP_ARCHIVE_TRAITS(cereal::JSONInputArchive, cereal::JSONOutputArchive) +#if defined(__clang__) or (defined(__GNUC__) and __GNUC__ >= 7) +CEREAL_RAPIDJSON_DIAG_POP +#endif + #endif // CEREAL_ARCHIVES_JSON_HPP_ From 01dd76f515ad0df682e5ff57e1fddb9f27cb8732 Mon Sep 17 00:00:00 2001 From: Furkan Usta Date: Mon, 4 Sep 2017 13:20:58 +0300 Subject: [PATCH 2/3] Added missing implicit fallthrough pragma (Related to #416) Also, this one fixes the forgotten pragma pop at the end of the header file --- include/cereal/external/rapidjson/internal/regex.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/cereal/external/rapidjson/internal/regex.h b/include/cereal/external/rapidjson/internal/regex.h index 3bfa3ec3e..81c51070f 100644 --- a/include/cereal/external/rapidjson/internal/regex.h +++ b/include/cereal/external/rapidjson/internal/regex.h @@ -29,6 +29,9 @@ CEREAL_RAPIDJSON_DIAG_OFF(implicit-fallthrough) #ifdef __GNUC__ CEREAL_RAPIDJSON_DIAG_PUSH CEREAL_RAPIDJSON_DIAG_OFF(effc++) +#if __GNUC__ >= 7 + CEREAL_RAPIDJSON_DIAG_OFF(implicit-fallthrough) +#endif #endif #ifdef _MSC_VER @@ -694,6 +697,10 @@ CEREAL_RAPIDJSON_NAMESPACE_END CEREAL_RAPIDJSON_DIAG_POP #endif +#ifdef __GNUC__ +CEREAL_RAPIDJSON_DIAG_POP +#endif + #ifdef _MSC_VER CEREAL_RAPIDJSON_DIAG_POP #endif From f7baa90c23c294d910aa47792b63950f38680d74 Mon Sep 17 00:00:00 2001 From: Furkan Usta Date: Thu, 7 Sep 2017 19:33:02 +0300 Subject: [PATCH 3/3] Changed 'and' 'or' operators with their symbolic counterparts Apparently literal words cause problems in MSVC --- include/cereal/archives/json.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cereal/archives/json.hpp b/include/cereal/archives/json.hpp index 2b17cf7a8..102f86e8d 100644 --- a/include/cereal/archives/json.hpp +++ b/include/cereal/archives/json.hpp @@ -68,7 +68,7 @@ namespace cereal #include #include -#if defined(__clang__) or (defined(__GNUC__) and __GNUC__ >= 7) +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 7) CEREAL_RAPIDJSON_DIAG_PUSH CEREAL_RAPIDJSON_DIAG_OFF(implicit-fallthrough) #endif @@ -1014,7 +1014,7 @@ CEREAL_REGISTER_ARCHIVE(cereal::JSONOutputArchive) // tie input and output archives together CEREAL_SETUP_ARCHIVE_TRAITS(cereal::JSONInputArchive, cereal::JSONOutputArchive) -#if defined(__clang__) or (defined(__GNUC__) and __GNUC__ >= 7) +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 7) CEREAL_RAPIDJSON_DIAG_POP #endif