Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5cd8f35
UPDATE: silence clang warning: unannotated fall-through between switc…
Sep 3, 2025
deb1078
UPDATE: check whether compiler supports __attribute__((fallthrough)) …
Sep 3, 2025
eb48177
Revert "UPDATE: check whether compiler supports __attribute__((fallth…
Sep 3, 2025
2f07842
UPDATE: introduce PCRE2_FALLTHROUGH macro to allow portable annotatio…
Sep 3, 2025
db25c8b
UPDATE: fix comment.
Sep 3, 2025
bd6fdc0
UPDATE: point out to use the define in conjunction with a comment (I …
Sep 3, 2025
04f83d2
UPDATE: use C comments. also add that explictly to the comment on how…
Sep 3, 2025
38a5f1c
UPDATE: use single line comment to show an example usage.
Sep 3, 2025
ddb0040
UPDATE: add -Wimplicit-fallthrough. I hope this is the correct spot t…
Sep 3, 2025
7a2c156
UPDATE: introduce __has_c_attribute to check whether compiler support…
Sep 3, 2025
1f8a83f
UPDATE: check the C standard version. replace [[fallthrough]] by [[__…
Sep 3, 2025
9a72a66
UPDATE: use underscored version of fallthrough attribute. mind that i…
Sep 3, 2025
4240786
UPDATE: first test C standard version then check for __fallthrough__ …
Sep 3, 2025
53f1896
UPDATE: add missing PCRE2_FALLTHROUGH for JIT compiler.
Sep 3, 2025
e666bb1
UPDATE: add further missing PCRE2_FALLTHROUGH for JIT compiler.
Sep 3, 2025
6a67aa2
UPDATE: (try to) fix compile issue of manyconfig test.
Sep 4, 2025
3c10689
Merge remote-tracking branch 'origin/master' into Gsus42-change
NWilson Sep 12, 2025
4a87255
Update with further changes from the sljit PRs
NWilson Sep 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
contents: read

env:
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings'
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings -Wimplicit-fallthrough'
CFLAGS_MSVC: '/W3'
CFLAGS_SOLARIS_CC: '-errtags=yes -erroff=E_STATEMENT_NOT_REACHED'
CMAKE_FLAGS: '-Wdev -Werror=dev -Wdeprecated -Werror=deprecated --warn-uninitialized'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
contents: read

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

Expand Down
8 changes: 4 additions & 4 deletions src/pcre2_auto_possess.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,21 +804,21 @@ for(;;)

case OP_NOT_DIGIT:
invert_bits = TRUE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_DIGIT:
set2 = (const uint8_t *)(cb->cbits + cbit_digit);
break;

case OP_NOT_WHITESPACE:
invert_bits = TRUE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_WHITESPACE:
set2 = (const uint8_t *)(cb->cbits + cbit_space);
break;

case OP_NOT_WORDCHAR:
invert_bits = TRUE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_WORDCHAR:
set2 = (const uint8_t *)(cb->cbits + cbit_word);
break;
Expand Down Expand Up @@ -1101,7 +1101,7 @@ for(;;)

case OP_NCLASS:
if (chr > 255) return FALSE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case OP_CLASS:
if (chr > 255) break;
Expand Down
34 changes: 17 additions & 17 deletions src/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ else

if (c >= CHAR_8) break;

/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

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

case ESC_S:
prop = ESC_P;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case ESC_s:
ascii_option = PCRE2_EXTRA_ASCII_BSS;
break;

case ESC_W:
prop = ESC_P;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case ESC_w:
ascii_option = PCRE2_EXTRA_ASCII_BSW;
break;
Expand Down Expand Up @@ -4560,7 +4560,7 @@ while (ptr < ptrend)

default:
PCRE2_DEBUG_UNREACHABLE();
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case ESC_A:
case ESC_Z:
Expand Down Expand Up @@ -5224,7 +5224,7 @@ while (ptr < ptrend)
++ptr;
goto FAILED_FORWARD;
}
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case CHAR_0: case CHAR_1: case CHAR_2: case CHAR_3: case CHAR_4:
case CHAR_5: case CHAR_6: case CHAR_7: case CHAR_8: case CHAR_9:
Expand Down Expand Up @@ -5974,7 +5974,7 @@ for (;;)
case OP_UCP_WORD_BOUNDARY:
case OP_NOT_UCP_WORD_BOUNDARY:
if (!skipassert) return code;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case OP_CALLOUT:
case OP_CREF:
Expand Down Expand Up @@ -6493,7 +6493,7 @@ for (;; pptr++)
case META_PRUNE:
case META_SKIP:
cb->had_pruneorskip = TRUE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case META_COMMIT:
case META_FAIL:
*code++ = verbops[(meta - META_MARK) >> 16];
Expand All @@ -6518,7 +6518,7 @@ for (;; pptr++)
case META_PRUNE_ARG:
case META_SKIP_ARG:
cb->had_pruneorskip = TRUE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case META_MARK:
case META_COMMIT_ARG:
VERB_ARG:
Expand Down Expand Up @@ -7498,7 +7498,7 @@ for (;; pptr++)
group_return = -1; /* Set "may match empty string" */

/* Now treat as a repeated OP_BRA. */
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

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

case ESC_A:
if (cb->max_lookbehind == 0) cb->max_lookbehind = 1;
Expand Down Expand Up @@ -9282,7 +9282,7 @@ do {

case OP_EXACT:
scode += IMM2_SIZE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case OP_CHAR:
case OP_PLUS:
Expand All @@ -9295,7 +9295,7 @@ do {

case OP_EXACTI:
scode += IMM2_SIZE;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case OP_CHARI:
case OP_PLUSI:
Expand Down Expand Up @@ -9727,7 +9727,7 @@ for (;; pptr++)
case META_BACKREF_BYNAME:
if ((cb->external_options & PCRE2_MATCH_UNSET_BACKREF) != 0)
goto ISNOTFIXED;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case META_RECURSE_BYNAME:
{
Expand Down Expand Up @@ -9776,7 +9776,7 @@ for (;; pptr++)
goto RECURSE_OR_BACKREF_LENGTH;
}

/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
/* For groups >= 10 - picking up group twice does no harm. */

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

case META_CAPTURE:
group = META_DATA(*pptr);
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case META_ATOMIC:
case META_NOCAPTURE:
Expand Down Expand Up @@ -9903,7 +9903,7 @@ for (;; pptr++)
else itemlength = (max - 1) * lastitemlength;
break;
}
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

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

Expand Down
4 changes: 2 additions & 2 deletions src/pcre2_compile_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ b) none of the cases here:
#define CLASS_END_CASES(meta) \
default: \
PCRE2_ASSERT((meta) <= META_END); \
/* Fall through */ \
PCRE2_FALLTHROUGH; /* Fall through */ \
case META_CLASS: \
case META_CLASS_NOT: \
case META_CLASS_EMPTY: \
Expand Down Expand Up @@ -2169,7 +2169,7 @@ switch (meta)
}

ptr++;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

default:
/* Scan forward characters, ranges, and properties.
Expand Down
8 changes: 4 additions & 4 deletions src/pcre2_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ while (plength > 0)
posix++;
continue; /* With next character after :] */
}
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case POSIX_CLASS_NOT_STARTED:
if (c == CHAR_LEFT_SQUARE_BRACKET)
Expand Down Expand Up @@ -321,15 +321,15 @@ while (plength > 0)

case CHAR_LEFT_PARENTHESIS:
bracount++;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case CHAR_QUESTION_MARK:
case CHAR_PLUS:
case CHAR_LEFT_CURLY_BRACKET:
case CHAR_RIGHT_CURLY_BRACKET:
case CHAR_VERTICAL_LINE:
if (!extended) goto ESCAPE_LITERAL;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case CHAR_DOT:
case CHAR_DOLLAR_SIGN:
Expand Down Expand Up @@ -358,7 +358,7 @@ while (plength > 0)
posix_state = POSIX_ANCHORED;
goto COPY_SPECIAL;
}
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

default:
if (c < 255 && strchr(pcre2_escaped_literals, c) != NULL)
Expand Down
12 changes: 6 additions & 6 deletions src/pcre2_dfa_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,7 @@ for (;;)
case 0x2029:
#endif /* Not EBCDIC */
if (mb->bsr_convention == PCRE2_BSR_ANYCRLF) break;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case CHAR_LF:
ADD_NEW(state_offset + 1, 0);
Expand Down Expand Up @@ -2440,7 +2440,7 @@ for (;;)
caseless = TRUE;
codevalue -= OP_STARI - OP_STAR;

/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_PLUS:
case OP_MINPLUS:
case OP_POSPLUS:
Expand Down Expand Up @@ -2484,7 +2484,7 @@ for (;;)
case OP_NOTPOSQUERYI:
caseless = TRUE;
codevalue -= OP_STARI - OP_STAR;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_QUERY:
case OP_MINQUERY:
case OP_POSQUERY:
Expand Down Expand Up @@ -2525,7 +2525,7 @@ for (;;)
case OP_NOTPOSSTARI:
caseless = TRUE;
codevalue -= OP_STARI - OP_STAR;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_STAR:
case OP_MINSTAR:
case OP_POSSTAR:
Expand Down Expand Up @@ -2562,7 +2562,7 @@ for (;;)
case OP_NOTEXACTI:
caseless = TRUE;
codevalue -= OP_STARI - OP_STAR;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_EXACT:
case OP_NOTEXACT:
count = current_state->count; /* Number already matched */
Expand Down Expand Up @@ -2597,7 +2597,7 @@ for (;;)
case OP_NOTPOSUPTOI:
caseless = TRUE;
codevalue -= OP_STARI - OP_STAR;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
case OP_UPTO:
case OP_MINUPTO:
case OP_POSUPTO:
Expand Down
18 changes: 9 additions & 9 deletions src/pcre2_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
Fecode += 1 + LINK_SIZE;
continue;
}
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

/* OP_END itself can never be reached within a recursion because that is
picked up when the OP_KET that always precedes OP_END is reached. */
Expand Down Expand Up @@ -1054,7 +1054,7 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
mb->hitend = TRUE;
if (mb->partial > 1) return PCRE2_ERROR_PARTIAL;
}
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

/* Match any single character whatsoever. */

Expand Down Expand Up @@ -6062,7 +6062,7 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
assert_accept_frame->offset_top * sizeof(PCRE2_SIZE));
Foffset_top = assert_accept_frame->offset_top;

/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
/* In the case of a match, the captures have already been put into
the current frame. */

Expand Down Expand Up @@ -6360,7 +6360,7 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
case OP_ASSERTBACK_NA:
if (branch_start[1 + LINK_SIZE] == OP_VREVERSE && Feptr != P->eptr)
RRETURN(MATCH_NOMATCH);
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case OP_ASSERT_NA:
if (Feptr > mb->last_used_ptr) mb->last_used_ptr = Feptr;
Expand All @@ -6374,12 +6374,12 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
case OP_ASSERTBACK:
if (branch_start[1 + LINK_SIZE] == OP_VREVERSE && Feptr != P->eptr)
RRETURN(MATCH_NOMATCH);
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case OP_ASSERT:
if (Feptr > mb->last_used_ptr) mb->last_used_ptr = Feptr;
Feptr = P->eptr;
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

/* For an atomic group, discard internal backtracking points. We must
also ensure that any remaining branches within the top-level of the group
Expand All @@ -6403,7 +6403,7 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
case OP_ASSERTBACK_NOT:
if (branch_start[1 + LINK_SIZE] == OP_VREVERSE && Feptr != P->eptr)
RRETURN(MATCH_NOMATCH);
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

case OP_ASSERT_NOT:
RRETURN(MATCH_MATCH);
Expand Down Expand Up @@ -6537,7 +6537,7 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
if ((mb->moptions & PCRE2_NOTEOL) != 0) RRETURN(MATCH_NOMATCH);
if ((mb->poptions & PCRE2_DOLLAR_ENDONLY) == 0) goto ASSERT_NL_OR_EOS;

/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */
/* Unconditional end of subject assertion (\z). */

case OP_EOD:
Expand Down Expand Up @@ -7938,7 +7938,7 @@ for(;;)
new_start_match = mb->verb_skip_ptr;
break;
}
/* Fall through */
PCRE2_FALLTHROUGH; /* Fall through */

/* NOMATCH and PRUNE advance by one character. THEN at this level acts
exactly like PRUNE. Unset ignore SKIP-with-argument. */
Expand Down
Loading
Loading