Port to clang 3.7.0 on x86-64

* configure.ac: Use AS_IF so that gl_WARN_ADD’s prerequisites are
not done conditionally.  This helps clang, which needs
-Wunknown-warning-option later when configured with warnings.
* src/editfns.c (invalid_time): Now _Noreturn, since clang isn’t
smart enough to figure this out on its own if warnings are enabled.
(lisp_time_struct): Redo for clarity, and to pacify clang.
* src/xfns.c (x_real_pos_and_offsets) [USE_XCB]: Don’t use
uninitialized locals.  This avoids undefined behavior and pacifies
clang.
This commit is contained in:
Paul Eggert 2016-03-15 13:47:47 -07:00
parent 218ae59019
commit 7950e1dd3f
3 changed files with 14 additions and 12 deletions

View file

@ -877,18 +877,19 @@ AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
# When compiling with GCC, prefer -isystem to -I when including system
# include files, to avoid generating useless diagnostics for the files.
if test "$gl_gcc_warnings" != yes; then
AS_IF([test "$gl_gcc_warnings" != yes],
[
isystem='-I'
if test "$emacs_cv_clang" = yes
then
AS_IF([test "$emacs_cv_clang" = yes],
[
# Turn off some warnings if supported.
gl_WARN_ADD([-Wno-switch])
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
gl_WARN_ADD([-Wno-pointer-sign])
gl_WARN_ADD([-Wno-string-plus-int])
gl_WARN_ADD([-Wno-unknown-attributes])
fi
else
])
],[
isystem='-isystem '
# This, $nw, is the list of warnings we disable.
@ -899,10 +900,9 @@ else
# Old toolkits mishandle 'const'.
nw="$nw -Wwrite-strings"
;;
*)
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
;;
esac
AS_IF([test -z "$nw"],
[gl_WARN_ADD([-Werror], [WERROR_CFLAGS])])
AC_SUBST([WERROR_CFLAGS])
nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
@ -985,7 +985,7 @@ else
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
fi
])
edit_cflags="
s,///*,/,g

View file

@ -1456,7 +1456,7 @@ time_overflow (void)
error ("Specified time is not representable");
}
static void
static _Noreturn void
invalid_time (void)
{
error ("Invalid time specification");
@ -1848,7 +1848,9 @@ lisp_time_struct (Lisp_Object specified_time, int *plen)
Lisp_Object high, low, usec, psec;
struct lisp_time t;
int len = disassemble_lisp_time (specified_time, &high, &low, &usec, &psec);
int val = len ? decode_time_components (high, low, usec, psec, &t, 0) : 0;
if (!len)
invalid_time ();
int val = decode_time_components (high, low, usec, psec, &t, 0);
check_time_validity (val);
*plen = len;
return t;

View file

@ -273,7 +273,7 @@ x_real_pos_and_offsets (struct frame *f,
XFree (tmp_children);
#endif
if (wm_window == rootw || had_errors)
if (had_errors || wm_window == rootw)
break;
win = wm_window;