diff --git a/src/coding.c b/src/coding.c index d5833a98c23..dd767c80ab4 100644 --- a/src/coding.c +++ b/src/coding.c @@ -159,6 +159,9 @@ detect_coding_XXX (struct coding_system *coding, const unsigned char *src = coding->source; const unsigned char *src_end = coding->source + coding->src_bytes; bool multibytep = coding->src_multibyte; + /* Some encodings do not need this variable, however it is incremented in the + ONE_MORE_BYTE macro. In that case mark it with MAYBE_UNUSED to silence + compiler warnings. */ ptrdiff_t consumed_chars = 0; int found = 0; ...; @@ -652,11 +655,6 @@ growable_destination (struct coding_system *coding) consumed_chars++; \ } while (0) -/* Suppress clang warnings about consumed_chars never being used. - Although correct, the warnings are too much trouble to code around. */ -#if 13 <= __clang_major__ - defined __apple_build_version__ -# pragma clang diagnostic ignored "-Wunused-but-set-variable" -#endif /* Safely get two bytes from the source text pointed by SRC which ends at SRC_END, and set C1 and C2 to those bytes while skipping the @@ -1135,7 +1133,7 @@ detect_coding_utf_8 (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; bool multibytep = coding->src_multibyte; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; bool bom_found = 0; ptrdiff_t nchars = coding->head_ascii; @@ -1843,7 +1841,7 @@ detect_coding_emacs_mule (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; bool multibytep = coding->src_multibyte; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; int c; int found = 0; @@ -2933,7 +2931,7 @@ detect_coding_iso_2022 (struct coding_system *coding, bool single_shifting = 0; int id; int c, c1; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; int i; int rejected = 0; int found = 0; @@ -4321,7 +4319,7 @@ encode_designation_at_bol (struct coding_system *coding, /* Table of charsets to be designated to each graphic register. */ int r[4]; int c, found = 0, reg; - ptrdiff_t produced_chars = 0; + MAYBE_UNUSED ptrdiff_t produced_chars = 0; bool multibytep = coding->dst_multibyte; Lisp_Object attrs; Lisp_Object charset_list; @@ -4583,7 +4581,7 @@ detect_coding_sjis (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; bool multibytep = coding->src_multibyte; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; int found = 0; int c; Lisp_Object attrs, charset_list; @@ -4638,7 +4636,7 @@ detect_coding_big5 (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; bool multibytep = coding->src_multibyte; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; int found = 0; int c; @@ -5076,7 +5074,7 @@ detect_coding_ccl (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; bool multibytep = coding->src_multibyte; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; int found = 0; unsigned char *valids; ptrdiff_t head_ascii = coding->head_ascii; @@ -5371,7 +5369,7 @@ detect_coding_charset (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; bool multibytep = coding->src_multibyte; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; Lisp_Object attrs, valids, name; int found = 0; ptrdiff_t head_ascii = coding->head_ascii; @@ -7100,7 +7098,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, if (coding->src_multibyte) { bool multibytep = 1; - ptrdiff_t consumed_chars = 0; + MAYBE_UNUSED ptrdiff_t consumed_chars = 0; while (1) {