Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Younger <crazyscot@gmail.com>2019-10-01 08:48:29 +0300
committerRoss Younger <crazyscot@gmail.com>2019-10-01 10:12:54 +0300
commit4116912cde6a9563faa3ebca40c872e05fc3a9ee (patch)
treed375f48856279f9b051b656aa0685c6f759d5e5a
parentd67a69a9cf64ed5984644fa061a2b14367fac820 (diff)
Use C++17 fallthrough tag instead of disabling warning
Signed-off-by: Ross Younger <crazyscot@gmail.com>
-rw-r--r--include/rapidjson/internal/regex.h7
-rw-r--r--include/rapidjson/rapidjson.h13
2 files changed, 16 insertions, 4 deletions
diff --git a/include/rapidjson/internal/regex.h b/include/rapidjson/internal/regex.h
index 16e35592..af7e06de 100644
--- a/include/rapidjson/internal/regex.h
+++ b/include/rapidjson/internal/regex.h
@@ -23,7 +23,6 @@
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(padded)
RAPIDJSON_DIAG_OFF(switch-enum)
-RAPIDJSON_DIAG_OFF(implicit-fallthrough)
#elif defined(_MSC_VER)
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
@@ -32,9 +31,6 @@ RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
#ifdef __GNUC__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
-#if __GNUC__ >= 7
-RAPIDJSON_DIAG_OFF(implicit-fallthrough)
-#endif
#endif
#ifndef RAPIDJSON_REGEX_VERBOSE
@@ -291,6 +287,7 @@ private:
if (!CharacterEscape(ds, &codepoint))
return; // Unsupported escape character
// fall through to default
+ RAPIDJSON_DELIBERATE_FALLTHROUGH;
default: // Pattern character
PushOperand(operandStack, codepoint);
@@ -520,6 +517,7 @@ private:
else if (!CharacterEscape(ds, &codepoint))
return false;
// fall through to default
+ RAPIDJSON_DELIBERATE_FALLTHROUGH;
default:
switch (step) {
@@ -529,6 +527,7 @@ private:
break;
}
// fall through to step 0 for other characters
+ RAPIDJSON_DELIBERATE_FALLTHROUGH;
case 0:
{
diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h
index 549936ff..5c638261 100644
--- a/include/rapidjson/rapidjson.h
+++ b/include/rapidjson/rapidjson.h
@@ -591,6 +591,19 @@ RAPIDJSON_NAMESPACE_END
#endif
#endif // RAPIDJSON_HAS_CXX11_RANGE_FOR
+///////////////////////////////////////////////////////////////////////////////
+// C++17 features
+
+#if defined(__has_cpp_attribute)
+# if __has_cpp_attribute(fallthrough)
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[fallthrough]]
+# else
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH
+# endif
+#else
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH
+#endif
+
//!@endcond
//! Assertion (in non-throwing contexts).