Skip to content

Commit 6a6bed2

Browse files
authored
Merge pull request Tencent#1582 from crazyscot/master
Use C++17 fallthrough tag instead of disabling compiler warning
2 parents 5592c2e + 4116912 commit 6a6bed2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

include/rapidjson/internal/regex.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
RAPIDJSON_DIAG_PUSH
2424
RAPIDJSON_DIAG_OFF(padded)
2525
RAPIDJSON_DIAG_OFF(switch-enum)
26-
RAPIDJSON_DIAG_OFF(implicit-fallthrough)
2726
#elif defined(_MSC_VER)
2827
RAPIDJSON_DIAG_PUSH
2928
RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
@@ -32,9 +31,6 @@ RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
3231
#ifdef __GNUC__
3332
RAPIDJSON_DIAG_PUSH
3433
RAPIDJSON_DIAG_OFF(effc++)
35-
#if __GNUC__ >= 7
36-
RAPIDJSON_DIAG_OFF(implicit-fallthrough)
37-
#endif
3834
#endif
3935

4036
#ifndef RAPIDJSON_REGEX_VERBOSE
@@ -291,6 +287,7 @@ class GenericRegex {
291287
if (!CharacterEscape(ds, &codepoint))
292288
return; // Unsupported escape character
293289
// fall through to default
290+
RAPIDJSON_DELIBERATE_FALLTHROUGH;
294291

295292
default: // Pattern character
296293
PushOperand(operandStack, codepoint);
@@ -520,6 +517,7 @@ class GenericRegex {
520517
else if (!CharacterEscape(ds, &codepoint))
521518
return false;
522519
// fall through to default
520+
RAPIDJSON_DELIBERATE_FALLTHROUGH;
523521

524522
default:
525523
switch (step) {
@@ -529,6 +527,7 @@ class GenericRegex {
529527
break;
530528
}
531529
// fall through to step 0 for other characters
530+
RAPIDJSON_DELIBERATE_FALLTHROUGH;
532531

533532
case 0:
534533
{

include/rapidjson/rapidjson.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,19 @@ RAPIDJSON_NAMESPACE_END
591591
#endif
592592
#endif // RAPIDJSON_HAS_CXX11_RANGE_FOR
593593

594+
///////////////////////////////////////////////////////////////////////////////
595+
// C++17 features
596+
597+
#if defined(__has_cpp_attribute)
598+
# if __has_cpp_attribute(fallthrough)
599+
# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[fallthrough]]
600+
# else
601+
# define RAPIDJSON_DELIBERATE_FALLTHROUGH
602+
# endif
603+
#else
604+
# define RAPIDJSON_DELIBERATE_FALLTHROUGH
605+
#endif
606+
594607
//!@endcond
595608

596609
//! Assertion (in non-throwing contexts).

0 commit comments

Comments
 (0)