From: Dmitry Antipov Date: Wed, 4 Jul 2012 08:07:26 +0000 (+0400) Subject: Fix compilation with --enable-gcc-warnings and -O1 X-Git-Tag: emacs-24.2.90~1199^2~230 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8ce70ed205e01913845330d084b9dd793b66d2c6;p=emacs.git Fix compilation with --enable-gcc-warnings and -O1 optimization level. * configure.in: If --enable-gcc-warnings, disable -Wunsafe-loop-optimizations for -O1 optimization level. * src/doprnt.c (doprnt): Change type of tem to int, initialize to avoid compiler warning. Add eassert. * src/search.c (simple_search): Initialize match_byte to avoid compiler warning. Add eassert. --- diff --git a/ChangeLog b/ChangeLog index db3dc32410d..95f0f0c1a20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-07-04 Dmitry Antipov + + * configure.in: If --enable-gcc-warnings, disable + -Wunsafe-loop-optimizations for -O1 optimization level. + 2012-06-30 Glenn Morris * configure.in (standardlisppath): New output variable. diff --git a/configure.in b/configure.in index 20b4cf2d593..dde8bcca855 100644 --- a/configure.in +++ b/configure.in @@ -681,6 +681,12 @@ else nw="$nw -Wsuggest-attribute=const" nw="$nw -Wsuggest-attribute=pure" + # Some loops can't be optimized with -O1, + # so remove -Wunsafe-loop-optimizations. + if echo "$CFLAGS" | $EGREP 'O1' 1>/dev/null; then + nw="$nw -Wunsafe-loop-optimizations" + fi + gl_MANYWARN_ALL_GCC([ws]) gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw]) for w in $ws; do diff --git a/src/ChangeLog b/src/ChangeLog index e335c8de8d4..065ff35ce77 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2012-07-04 Dmitry Antipov + + Fix compilation with --enable-gcc-warnings and -O1 + optimization level. + * doprnt.c (doprnt): Change type of tem to int, initialize + to avoid compiler warning. Add eassert. + * search.c (simple_search): Initialize match_byte to avoid + compiler warning. Add eassert. + 2012-07-04 Paul Eggert Avoid weird behavior with large horizontal scrolls. diff --git a/src/doprnt.c b/src/doprnt.c index 07bbcff7081..707dd0648b5 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -150,7 +150,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, /* Buffer we have got with malloc. */ char *big_buffer = NULL; - register size_t tem; + register int tem = -1; char *string; char fixed_buffer[20]; /* Default buffer for small formatting. */ char *fmtcpy; @@ -368,6 +368,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, /* Copy string into final output, truncating if no room. */ doit: + eassert (tem != -1); /* Coming here means STRING contains ASCII only. */ if (STRING_BYTES_BOUND < tem) error ("Format width or precision too large"); diff --git a/src/search.c b/src/search.c index 4912c0f23ec..11f51d87a7d 100644 --- a/src/search.c +++ b/src/search.c @@ -1451,7 +1451,7 @@ simple_search (EMACS_INT n, unsigned char *pat, int forward = n > 0; /* Number of buffer bytes matched. Note that this may be different from len_byte in a multibyte buffer. */ - ptrdiff_t match_byte; + ptrdiff_t match_byte = PTRDIFF_MIN; if (lim > pos && multibyte) while (n > 0) @@ -1622,6 +1622,7 @@ simple_search (EMACS_INT n, unsigned char *pat, stop: if (n == 0) { + eassert (match_byte != PTRDIFF_MIN); if (forward) set_search_regs ((multibyte ? pos_byte : pos) - match_byte, match_byte); else