From: Paul Eggert Date: Fri, 15 Nov 2013 18:01:04 +0000 (-0800) Subject: * data.c: Work around bogus GCC diagnostic about shift count. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~814 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2fcc742fc5c1a8de794d78a32c0c0fbf4629ca92;p=emacs.git * data.c: Work around bogus GCC diagnostic about shift count. Reported by Eli Zaretskii in . (pre_value): New function. (count_trailing_zero_bits): Use it. --- diff --git a/src/ChangeLog b/src/ChangeLog index 14de1e793b5..f92eb7b85fc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2013-11-15 Paul Eggert + + * data.c: Work around bogus GCC diagnostic about shift count. + Reported by Eli Zaretskii in + . + (pre_value): New function. + (count_trailing_zero_bits): Use it. + 2013-11-15 Eli Zaretskii * lisp.h (DEBUGGER_SEES_C_MACROS) [GCC < v3.5]: Pessimistically diff --git a/src/data.c b/src/data.c index 7ff7ac6b130..d0171b5d758 100644 --- a/src/data.c +++ b/src/data.c @@ -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); } }