* data.c: Work around bogus GCC diagnostic about shift count.

Reported by Eli Zaretskii in
<http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00489.html>.
(pre_value): New function.
(count_trailing_zero_bits): Use it.
This commit is contained in:
Paul Eggert 2013-11-15 10:01:04 -08:00
parent 82407168e6
commit 2fcc742fc5
2 changed files with 20 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2013-11-15 Paul Eggert <eggert@cs.ucla.edu>
* data.c: Work around bogus GCC diagnostic about shift count.
Reported by Eli Zaretskii in
<http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00489.html>.
(pre_value): New function.
(count_trailing_zero_bits): Use it.
2013-11-15 Eli Zaretskii <eliz@gnu.org>
* lisp.h (DEBUGGER_SEES_C_MACROS) [GCC < v3.5]: Pessimistically

View file

@ -3078,6 +3078,16 @@ bool_vector_binop_driver (Lisp_Object op1,
return changed ? dest : Qnil;
}
/* PRECONDITION must be true. Return VALUE. This odd construction
works around a bogus GCC diagnostic "shift count >= width of type". */
static int
pre_value (bool precondition, int value)
{
eassume (precondition);
return precondition ? value : 0;
}
/* Compute the number of trailing zero bits in val. If val is zero,
return the number of bits in val. */
static int
@ -3111,7 +3121,8 @@ count_trailing_zero_bits (bits_word val)
if (BITS_PER_BITS_WORD % BITS_PER_ULL != 0
&& BITS_WORD_MAX == (bits_word) -1)
val |= (bits_word) 1 << (BITS_PER_BITS_WORD % BITS_PER_ULL);
val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX,
BITS_PER_BITS_WORD % BITS_PER_ULL);
return count + count_trailing_zeros_ll (val);
}
}