Skip to content

Commit 7525365

Browse files
Gsus42Gernot GebhardNWilson
authored
Silence clang compiler warning: unannotated fall-through between switch labels (#789)
Co-authored-by: Gernot Gebhard <[email protected]> Co-authored-by: Nicholas Wilson <[email protected]>
1 parent 0686e42 commit 7525365

15 files changed

+130
-87
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
contents: read
1111

1212
env:
13-
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings'
13+
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings -Wimplicit-fallthrough'
1414
CFLAGS_MSVC: '/W3'
1515
CFLAGS_SOLARIS_CC: '-errtags=yes -erroff=E_STATEMENT_NOT_REACHED'
1616
CMAKE_FLAGS: '-Wdev -Werror=dev -Wdeprecated -Werror=deprecated --warn-uninitialized'

.github/workflows/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
contents: read
1111

1212
env:
13-
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings'
13+
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings -Wimplicit-fallthrough'
1414
CFLAGS_MSVC: '/W3'
1515
CMAKE_FLAGS: '-Wdev -Werror=dev -Wdeprecated -Werror=deprecated --warn-uninitialized'
1616

src/pcre2_auto_possess.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,21 +804,21 @@ for(;;)
804804

805805
case OP_NOT_DIGIT:
806806
invert_bits = TRUE;
807-
/* Fall through */
807+
PCRE2_FALLTHROUGH /* Fall through */
808808
case OP_DIGIT:
809809
set2 = (const uint8_t *)(cb->cbits + cbit_digit);
810810
break;
811811

812812
case OP_NOT_WHITESPACE:
813813
invert_bits = TRUE;
814-
/* Fall through */
814+
PCRE2_FALLTHROUGH /* Fall through */
815815
case OP_WHITESPACE:
816816
set2 = (const uint8_t *)(cb->cbits + cbit_space);
817817
break;
818818

819819
case OP_NOT_WORDCHAR:
820820
invert_bits = TRUE;
821-
/* Fall through */
821+
PCRE2_FALLTHROUGH /* Fall through */
822822
case OP_WORDCHAR:
823823
set2 = (const uint8_t *)(cb->cbits + cbit_word);
824824
break;
@@ -1101,7 +1101,7 @@ for(;;)
11011101

11021102
case OP_NCLASS:
11031103
if (chr > 255) return FALSE;
1104-
/* Fall through */
1104+
PCRE2_FALLTHROUGH /* Fall through */
11051105

11061106
case OP_CLASS:
11071107
if (chr > 255) break;

src/pcre2_compile.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ else
19361936

19371937
if (c >= CHAR_8) break;
19381938

1939-
/* Fall through */
1939+
PCRE2_FALLTHROUGH /* Fall through */
19401940

19411941
/* \0 always starts an octal number, but we may drop through to here with a
19421942
larger first octal digit. The original code used just to take the least
@@ -2908,21 +2908,21 @@ switch(escape)
29082908
{
29092909
case ESC_D:
29102910
prop = ESC_P;
2911-
/* Fall through */
2911+
PCRE2_FALLTHROUGH /* Fall through */
29122912
case ESC_d:
29132913
ascii_option = PCRE2_EXTRA_ASCII_BSD;
29142914
break;
29152915

29162916
case ESC_S:
29172917
prop = ESC_P;
2918-
/* Fall through */
2918+
PCRE2_FALLTHROUGH /* Fall through */
29192919
case ESC_s:
29202920
ascii_option = PCRE2_EXTRA_ASCII_BSS;
29212921
break;
29222922

29232923
case ESC_W:
29242924
prop = ESC_P;
2925-
/* Fall through */
2925+
PCRE2_FALLTHROUGH /* Fall through */
29262926
case ESC_w:
29272927
ascii_option = PCRE2_EXTRA_ASCII_BSW;
29282928
break;
@@ -4560,7 +4560,7 @@ while (ptr < ptrend)
45604560

45614561
default:
45624562
PCRE2_DEBUG_UNREACHABLE();
4563-
/* Fall through */
4563+
PCRE2_FALLTHROUGH /* Fall through */
45644564

45654565
case ESC_A:
45664566
case ESC_Z:
@@ -5224,7 +5224,7 @@ while (ptr < ptrend)
52245224
++ptr;
52255225
goto FAILED_FORWARD;
52265226
}
5227-
/* Fall through */
5227+
PCRE2_FALLTHROUGH /* Fall through */
52285228

52295229
case CHAR_0: case CHAR_1: case CHAR_2: case CHAR_3: case CHAR_4:
52305230
case CHAR_5: case CHAR_6: case CHAR_7: case CHAR_8: case CHAR_9:
@@ -5974,7 +5974,7 @@ for (;;)
59745974
case OP_UCP_WORD_BOUNDARY:
59755975
case OP_NOT_UCP_WORD_BOUNDARY:
59765976
if (!skipassert) return code;
5977-
/* Fall through */
5977+
PCRE2_FALLTHROUGH /* Fall through */
59785978

59795979
case OP_CALLOUT:
59805980
case OP_CREF:
@@ -6493,7 +6493,7 @@ for (;; pptr++)
64936493
case META_PRUNE:
64946494
case META_SKIP:
64956495
cb->had_pruneorskip = TRUE;
6496-
/* Fall through */
6496+
PCRE2_FALLTHROUGH /* Fall through */
64976497
case META_COMMIT:
64986498
case META_FAIL:
64996499
*code++ = verbops[(meta - META_MARK) >> 16];
@@ -6518,7 +6518,7 @@ for (;; pptr++)
65186518
case META_PRUNE_ARG:
65196519
case META_SKIP_ARG:
65206520
cb->had_pruneorskip = TRUE;
6521-
/* Fall through */
6521+
PCRE2_FALLTHROUGH /* Fall through */
65226522
case META_MARK:
65236523
case META_COMMIT_ARG:
65246524
VERB_ARG:
@@ -7498,7 +7498,7 @@ for (;; pptr++)
74987498
group_return = -1; /* Set "may match empty string" */
74997499

75007500
/* Now treat as a repeated OP_BRA. */
7501-
/* Fall through */
7501+
PCRE2_FALLTHROUGH /* Fall through */
75027502

75037503
/* If previous was a bracket group, we may have to replicate it in
75047504
certain cases. Note that at this point we can encounter only the "basic"
@@ -8348,7 +8348,7 @@ for (;; pptr++)
83488348
if ((options & PCRE2_UCP) != 0 && (xoptions & PCRE2_EXTRA_ASCII_BSW) == 0)
83498349
meta_arg = (meta_arg == ESC_B)? OP_NOT_UCP_WORD_BOUNDARY :
83508350
OP_UCP_WORD_BOUNDARY;
8351-
/* Fall through */
8351+
PCRE2_FALLTHROUGH /* Fall through */
83528352

83538353
case ESC_A:
83548354
if (cb->max_lookbehind == 0) cb->max_lookbehind = 1;
@@ -9282,7 +9282,7 @@ do {
92829282

92839283
case OP_EXACT:
92849284
scode += IMM2_SIZE;
9285-
/* Fall through */
9285+
PCRE2_FALLTHROUGH /* Fall through */
92869286

92879287
case OP_CHAR:
92889288
case OP_PLUS:
@@ -9295,7 +9295,7 @@ do {
92959295

92969296
case OP_EXACTI:
92979297
scode += IMM2_SIZE;
9298-
/* Fall through */
9298+
PCRE2_FALLTHROUGH /* Fall through */
92999299

93009300
case OP_CHARI:
93019301
case OP_PLUSI:
@@ -9727,7 +9727,7 @@ for (;; pptr++)
97279727
case META_BACKREF_BYNAME:
97289728
if ((cb->external_options & PCRE2_MATCH_UNSET_BACKREF) != 0)
97299729
goto ISNOTFIXED;
9730-
/* Fall through */
9730+
PCRE2_FALLTHROUGH /* Fall through */
97319731

97329732
case META_RECURSE_BYNAME:
97339733
{
@@ -9776,7 +9776,7 @@ for (;; pptr++)
97769776
goto RECURSE_OR_BACKREF_LENGTH;
97779777
}
97789778

9779-
/* Fall through */
9779+
PCRE2_FALLTHROUGH /* Fall through */
97809780
/* For groups >= 10 - picking up group twice does no harm. */
97819781

97829782
/* A true recursion implies not fixed length, but a subroutine call may
@@ -9856,7 +9856,7 @@ for (;; pptr++)
98569856

98579857
case META_CAPTURE:
98589858
group = META_DATA(*pptr);
9859-
/* Fall through */
9859+
PCRE2_FALLTHROUGH /* Fall through */
98609860

98619861
case META_ATOMIC:
98629862
case META_NOCAPTURE:
@@ -9903,7 +9903,7 @@ for (;; pptr++)
99039903
else itemlength = (max - 1) * lastitemlength;
99049904
break;
99059905
}
9906-
/* Fall through */
9906+
PCRE2_FALLTHROUGH /* Fall through */
99079907

99089908
/* Any other item means this branch does not have a fixed length. */
99099909

src/pcre2_compile_class.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ b) none of the cases here:
6565
#define CLASS_END_CASES(meta) \
6666
default: \
6767
PCRE2_ASSERT((meta) <= META_END); \
68-
/* Fall through */ \
68+
PCRE2_FALLTHROUGH /* Fall through */ \
6969
case META_CLASS: \
7070
case META_CLASS_NOT: \
7171
case META_CLASS_EMPTY: \
@@ -2169,7 +2169,7 @@ switch (meta)
21692169
}
21702170

21712171
ptr++;
2172-
/* Fall through */
2172+
PCRE2_FALLTHROUGH /* Fall through */
21732173

21742174
default:
21752175
/* Scan forward characters, ranges, and properties.

src/pcre2_convert.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ while (plength > 0)
226226
posix++;
227227
continue; /* With next character after :] */
228228
}
229-
/* Fall through */
229+
PCRE2_FALLTHROUGH /* Fall through */
230230

231231
case POSIX_CLASS_NOT_STARTED:
232232
if (c == CHAR_LEFT_SQUARE_BRACKET)
@@ -321,15 +321,15 @@ while (plength > 0)
321321

322322
case CHAR_LEFT_PARENTHESIS:
323323
bracount++;
324-
/* Fall through */
324+
PCRE2_FALLTHROUGH /* Fall through */
325325

326326
case CHAR_QUESTION_MARK:
327327
case CHAR_PLUS:
328328
case CHAR_LEFT_CURLY_BRACKET:
329329
case CHAR_RIGHT_CURLY_BRACKET:
330330
case CHAR_VERTICAL_LINE:
331331
if (!extended) goto ESCAPE_LITERAL;
332-
/* Fall through */
332+
PCRE2_FALLTHROUGH /* Fall through */
333333

334334
case CHAR_DOT:
335335
case CHAR_DOLLAR_SIGN:
@@ -358,7 +358,7 @@ while (plength > 0)
358358
posix_state = POSIX_ANCHORED;
359359
goto COPY_SPECIAL;
360360
}
361-
/* Fall through */
361+
PCRE2_FALLTHROUGH /* Fall through */
362362

363363
default:
364364
if (c < 255 && strchr(pcre2_escaped_literals, c) != NULL)

src/pcre2_dfa_match.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,7 @@ for (;;)
23282328
case 0x2029:
23292329
#endif /* Not EBCDIC */
23302330
if (mb->bsr_convention == PCRE2_BSR_ANYCRLF) break;
2331-
/* Fall through */
2331+
PCRE2_FALLTHROUGH /* Fall through */
23322332

23332333
case CHAR_LF:
23342334
ADD_NEW(state_offset + 1, 0);
@@ -2440,7 +2440,7 @@ for (;;)
24402440
caseless = TRUE;
24412441
codevalue -= OP_STARI - OP_STAR;
24422442

2443-
/* Fall through */
2443+
PCRE2_FALLTHROUGH /* Fall through */
24442444
case OP_PLUS:
24452445
case OP_MINPLUS:
24462446
case OP_POSPLUS:
@@ -2484,7 +2484,7 @@ for (;;)
24842484
case OP_NOTPOSQUERYI:
24852485
caseless = TRUE;
24862486
codevalue -= OP_STARI - OP_STAR;
2487-
/* Fall through */
2487+
PCRE2_FALLTHROUGH /* Fall through */
24882488
case OP_QUERY:
24892489
case OP_MINQUERY:
24902490
case OP_POSQUERY:
@@ -2525,7 +2525,7 @@ for (;;)
25252525
case OP_NOTPOSSTARI:
25262526
caseless = TRUE;
25272527
codevalue -= OP_STARI - OP_STAR;
2528-
/* Fall through */
2528+
PCRE2_FALLTHROUGH /* Fall through */
25292529
case OP_STAR:
25302530
case OP_MINSTAR:
25312531
case OP_POSSTAR:
@@ -2562,7 +2562,7 @@ for (;;)
25622562
case OP_NOTEXACTI:
25632563
caseless = TRUE;
25642564
codevalue -= OP_STARI - OP_STAR;
2565-
/* Fall through */
2565+
PCRE2_FALLTHROUGH /* Fall through */
25662566
case OP_EXACT:
25672567
case OP_NOTEXACT:
25682568
count = current_state->count; /* Number already matched */
@@ -2597,7 +2597,7 @@ for (;;)
25972597
case OP_NOTPOSUPTOI:
25982598
caseless = TRUE;
25992599
codevalue -= OP_STARI - OP_STAR;
2600-
/* Fall through */
2600+
PCRE2_FALLTHROUGH /* Fall through */
26012601
case OP_UPTO:
26022602
case OP_MINUPTO:
26032603
case OP_POSUPTO:

src/pcre2_jit_char_inc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ while (*cc == XCL_PROP || *cc == XCL_NOTPROP)
570570
break;
571571
}
572572
compares++;
573-
/* Fall through */
573+
PCRE2_FALLTHROUGH /* Fall through */
574574

575575
case PT_SC:
576576
status |= XCLASS_HAS_SCRIPT;
@@ -770,7 +770,7 @@ if (status & XCLASS_NEEDS_UCD)
770770
case PT_SCX:
771771
if (cc[-1] == XCL_NOTPROP)
772772
break;
773-
/* Fall through */
773+
PCRE2_FALLTHROUGH /* Fall through */
774774

775775
case PT_SC:
776776
compares--;

0 commit comments

Comments
 (0)