mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-21 06:55:39 +00:00
Pacify clang without munging C source
* configure.ac (WARN_CFLAGS): With Clang, use -Wno-tautological-compare regardless of --enable-gcc-warnings. (WERROR_CFLAGS): Simplify assignments, and guarantee it’s always set. * lib/strftime.c: Copy from gnulib, reverting Clang-specific change which I hope is no longer needed. * src/emacs.c (main): Revert rlim_t change, as rlim_t is signed on some older non-POSIX hosts.
This commit is contained in:
parent
2b9620e6af
commit
21d10e59f8
40
configure.ac
40
configure.ac
@ -891,6 +891,7 @@ AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
|
||||
[emacs_cv_clang=yes],
|
||||
[emacs_cv_clang=no])])
|
||||
|
||||
WERROR_CFLAGS=
|
||||
# When compiling with GCC, prefer -isystem to -I when including system
|
||||
# include files, to avoid generating useless diagnostics for the files.
|
||||
AS_IF([test $gl_gcc_warnings = no],
|
||||
@ -900,7 +901,6 @@ AS_IF([test $gl_gcc_warnings = no],
|
||||
[
|
||||
# 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])
|
||||
@ -918,8 +918,7 @@ AS_IF([test $gl_gcc_warnings = no],
|
||||
;;
|
||||
esac
|
||||
AS_IF([test $gl_gcc_warnings = yes],
|
||||
[gl_WARN_ADD([-Werror], [WERROR_CFLAGS])])
|
||||
AC_SUBST([WERROR_CFLAGS])
|
||||
[WERROR_CFLAGS=-Werror])
|
||||
|
||||
nw="$nw -Wduplicated-branches" # Too many false alarms
|
||||
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776
|
||||
@ -961,7 +960,7 @@ AS_IF([test $gl_gcc_warnings = no],
|
||||
nw="$nw -Wtype-limits"
|
||||
nw="$nw -Wunused-parameter"
|
||||
|
||||
if test $emacs_cv_clang = yes; then
|
||||
if test "$emacs_cv_clang" = yes; then
|
||||
nw="$nw -Wcast-align"
|
||||
nw="$nw -Wdouble-promotion"
|
||||
nw="$nw -Wmissing-braces"
|
||||
@ -984,11 +983,9 @@ AS_IF([test $gl_gcc_warnings = no],
|
||||
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-format-nonliteral])
|
||||
|
||||
# More things that clang is unduly picky about.
|
||||
if test $emacs_cv_clang = yes; then
|
||||
# clang is unduly picky about braces.
|
||||
if test "$emacs_cv_clang" = yes; then
|
||||
gl_WARN_ADD([-Wno-missing-braces])
|
||||
gl_WARN_ADD([-Wno-tautological-compare])
|
||||
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
|
||||
fi
|
||||
|
||||
# This causes too much noise in the MinGW build
|
||||
@ -1006,16 +1003,23 @@ AS_IF([test $gl_gcc_warnings = no],
|
||||
# define _FORTIFY_SOURCE 2
|
||||
#endif
|
||||
])
|
||||
|
||||
# We use a slightly smaller set of warning options for lib/.
|
||||
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
|
||||
nw=
|
||||
nw="$nw -Wunused-macros"
|
||||
|
||||
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||
AC_SUBST([GNULIB_WARN_CFLAGS])
|
||||
])
|
||||
|
||||
# clang is unduly picky about these regardless of whether
|
||||
# --enable-gcc-warnings is specified.
|
||||
if test "$emacs_cv_clang" = yes; then
|
||||
gl_WARN_ADD([-Wno-tautological-compare])
|
||||
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
|
||||
fi
|
||||
|
||||
# Use a slightly smaller set of warning options for lib/.
|
||||
nw=
|
||||
nw="$nw -Wunused-macros"
|
||||
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||
|
||||
AC_SUBST([WERROR_CFLAGS])
|
||||
AC_SUBST([GNULIB_WARN_CFLAGS])
|
||||
|
||||
edit_cflags="
|
||||
s,///*,/,g
|
||||
s/^/ /
|
||||
@ -1033,7 +1037,7 @@ AC_ARG_ENABLE(link-time-optimization,
|
||||
recommended for typical use.])],
|
||||
if test "${enableval}" != "no"; then
|
||||
ac_lto_supported=no
|
||||
if test $emacs_cv_clang = yes; then
|
||||
if test "$emacs_cv_clang" = yes; then
|
||||
AC_MSG_CHECKING([whether link-time optimization is supported by clang])
|
||||
GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null`
|
||||
if test -x "$GOLD_PLUGIN"; then
|
||||
@ -1062,7 +1066,7 @@ if test "${enableval}" != "no"; then
|
||||
AC_MSG_RESULT([$ac_lto_supported])
|
||||
if test "$ac_lto_supported" = "yes"; then
|
||||
CFLAGS="$CFLAGS $LTO"
|
||||
if test x$emacs_cv_clang = xyes; then
|
||||
if test "$emacs_cv_clang" = yes; then
|
||||
AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang])
|
||||
# WARNING: 'ar --plugin ...' doesn't work without
|
||||
# command, so plugin name is appended to ARFLAGS.
|
||||
|
@ -1123,23 +1123,18 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
|
||||
if (modifier == L_('E'))
|
||||
goto bad_format;
|
||||
|
||||
{
|
||||
/* Use a new variable here instead of reusing number_value
|
||||
because Clang complains about the self-assignment
|
||||
generated by DO_NUMBER. */
|
||||
ptrdiff_t n = ns;
|
||||
if (width == -1)
|
||||
width = 9;
|
||||
else
|
||||
{
|
||||
/* Take an explicit width less than 9 as a precision. */
|
||||
int j;
|
||||
for (j = width; j < 9; j++)
|
||||
n /= 10;
|
||||
}
|
||||
number_value = ns;
|
||||
if (width == -1)
|
||||
width = 9;
|
||||
else
|
||||
{
|
||||
/* Take an explicit width less than 9 as a precision. */
|
||||
int j;
|
||||
for (j = width; j < 9; j++)
|
||||
number_value /= 10;
|
||||
}
|
||||
|
||||
DO_NUMBER (width, n);
|
||||
}
|
||||
DO_NUMBER (width, number_value);
|
||||
#endif
|
||||
|
||||
case L_('n'):
|
||||
|
@ -832,7 +832,7 @@ main (int argc, char **argv)
|
||||
(https://www.cygwin.com/ml/cygwin/2015-07/msg00096.html). */
|
||||
struct rlimit rlim;
|
||||
if (getrlimit (RLIMIT_STACK, &rlim) == 0
|
||||
&& rlim.rlim_cur <= LONG_MAX)
|
||||
&& 0 <= rlim.rlim_cur && rlim.rlim_cur <= LONG_MAX)
|
||||
{
|
||||
rlim_t lim = rlim.rlim_cur;
|
||||
|
||||
@ -866,7 +866,7 @@ main (int argc, char **argv)
|
||||
right thing anyway. */
|
||||
long pagesize = getpagesize ();
|
||||
newlim += pagesize - 1;
|
||||
if (rlim.rlim_max < newlim)
|
||||
if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
|
||||
newlim = rlim.rlim_max;
|
||||
newlim -= newlim % pagesize;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user