diff options
| author | Paul Eggert | 2017-06-15 13:29:04 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-06-15 13:30:30 -0700 |
| commit | 21d10e59f89a5bb72829ffb8ebe4463ba4fac124 (patch) | |
| tree | 5e6d98853562542a09f4bf6cd09d0ec7221ef621 | |
| parent | 2b9620e6af80a1ce57321bc32d126b602ca493ce (diff) | |
| download | emacs-21d10e59f89a5bb72829ffb8ebe4463ba4fac124.tar.gz emacs-21d10e59f89a5bb72829ffb8ebe4463ba4fac124.zip | |
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.
| -rw-r--r-- | configure.ac | 38 | ||||
| -rw-r--r-- | lib/strftime.c | 27 | ||||
| -rw-r--r-- | src/emacs.c | 4 |
3 files changed, 34 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac index 459e314b597..9069e5b58ca 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -891,6 +891,7 @@ AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang], | |||
| 891 | [emacs_cv_clang=yes], | 891 | [emacs_cv_clang=yes], |
| 892 | [emacs_cv_clang=no])]) | 892 | [emacs_cv_clang=no])]) |
| 893 | 893 | ||
| 894 | WERROR_CFLAGS= | ||
| 894 | # When compiling with GCC, prefer -isystem to -I when including system | 895 | # When compiling with GCC, prefer -isystem to -I when including system |
| 895 | # include files, to avoid generating useless diagnostics for the files. | 896 | # include files, to avoid generating useless diagnostics for the files. |
| 896 | AS_IF([test $gl_gcc_warnings = no], | 897 | AS_IF([test $gl_gcc_warnings = no], |
| @@ -900,7 +901,6 @@ AS_IF([test $gl_gcc_warnings = no], | |||
| 900 | [ | 901 | [ |
| 901 | # Turn off some warnings if supported. | 902 | # Turn off some warnings if supported. |
| 902 | gl_WARN_ADD([-Wno-switch]) | 903 | gl_WARN_ADD([-Wno-switch]) |
| 903 | gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare]) | ||
| 904 | gl_WARN_ADD([-Wno-pointer-sign]) | 904 | gl_WARN_ADD([-Wno-pointer-sign]) |
| 905 | gl_WARN_ADD([-Wno-string-plus-int]) | 905 | gl_WARN_ADD([-Wno-string-plus-int]) |
| 906 | gl_WARN_ADD([-Wno-unknown-attributes]) | 906 | gl_WARN_ADD([-Wno-unknown-attributes]) |
| @@ -918,8 +918,7 @@ AS_IF([test $gl_gcc_warnings = no], | |||
| 918 | ;; | 918 | ;; |
| 919 | esac | 919 | esac |
| 920 | AS_IF([test $gl_gcc_warnings = yes], | 920 | AS_IF([test $gl_gcc_warnings = yes], |
| 921 | [gl_WARN_ADD([-Werror], [WERROR_CFLAGS])]) | 921 | [WERROR_CFLAGS=-Werror]) |
| 922 | AC_SUBST([WERROR_CFLAGS]) | ||
| 923 | 922 | ||
| 924 | nw="$nw -Wduplicated-branches" # Too many false alarms | 923 | nw="$nw -Wduplicated-branches" # Too many false alarms |
| 925 | nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776 | 924 | nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776 |
| @@ -961,7 +960,7 @@ AS_IF([test $gl_gcc_warnings = no], | |||
| 961 | nw="$nw -Wtype-limits" | 960 | nw="$nw -Wtype-limits" |
| 962 | nw="$nw -Wunused-parameter" | 961 | nw="$nw -Wunused-parameter" |
| 963 | 962 | ||
| 964 | if test $emacs_cv_clang = yes; then | 963 | if test "$emacs_cv_clang" = yes; then |
| 965 | nw="$nw -Wcast-align" | 964 | nw="$nw -Wcast-align" |
| 966 | nw="$nw -Wdouble-promotion" | 965 | nw="$nw -Wdouble-promotion" |
| 967 | nw="$nw -Wmissing-braces" | 966 | nw="$nw -Wmissing-braces" |
| @@ -984,11 +983,9 @@ AS_IF([test $gl_gcc_warnings = no], | |||
| 984 | gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now | 983 | gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now |
| 985 | gl_WARN_ADD([-Wno-format-nonliteral]) | 984 | gl_WARN_ADD([-Wno-format-nonliteral]) |
| 986 | 985 | ||
| 987 | # More things that clang is unduly picky about. | 986 | # clang is unduly picky about braces. |
| 988 | if test $emacs_cv_clang = yes; then | 987 | if test "$emacs_cv_clang" = yes; then |
| 989 | gl_WARN_ADD([-Wno-missing-braces]) | 988 | gl_WARN_ADD([-Wno-missing-braces]) |
| 990 | gl_WARN_ADD([-Wno-tautological-compare]) | ||
| 991 | gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare]) | ||
| 992 | fi | 989 | fi |
| 993 | 990 | ||
| 994 | # This causes too much noise in the MinGW build | 991 | # This causes too much noise in the MinGW build |
| @@ -1006,15 +1003,22 @@ AS_IF([test $gl_gcc_warnings = no], | |||
| 1006 | # define _FORTIFY_SOURCE 2 | 1003 | # define _FORTIFY_SOURCE 2 |
| 1007 | #endif | 1004 | #endif |
| 1008 | ]) | 1005 | ]) |
| 1006 | ]) | ||
| 1009 | 1007 | ||
| 1010 | # We use a slightly smaller set of warning options for lib/. | 1008 | # clang is unduly picky about these regardless of whether |
| 1011 | # Remove the following and save the result in GNULIB_WARN_CFLAGS. | 1009 | # --enable-gcc-warnings is specified. |
| 1012 | nw= | 1010 | if test "$emacs_cv_clang" = yes; then |
| 1013 | nw="$nw -Wunused-macros" | 1011 | gl_WARN_ADD([-Wno-tautological-compare]) |
| 1012 | gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare]) | ||
| 1013 | fi | ||
| 1014 | 1014 | ||
| 1015 | gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw]) | 1015 | # Use a slightly smaller set of warning options for lib/. |
| 1016 | AC_SUBST([GNULIB_WARN_CFLAGS]) | 1016 | nw= |
| 1017 | ]) | 1017 | nw="$nw -Wunused-macros" |
| 1018 | gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw]) | ||
| 1019 | |||
| 1020 | AC_SUBST([WERROR_CFLAGS]) | ||
| 1021 | AC_SUBST([GNULIB_WARN_CFLAGS]) | ||
| 1018 | 1022 | ||
| 1019 | edit_cflags=" | 1023 | edit_cflags=" |
| 1020 | s,///*,/,g | 1024 | s,///*,/,g |
| @@ -1033,7 +1037,7 @@ AC_ARG_ENABLE(link-time-optimization, | |||
| 1033 | recommended for typical use.])], | 1037 | recommended for typical use.])], |
| 1034 | if test "${enableval}" != "no"; then | 1038 | if test "${enableval}" != "no"; then |
| 1035 | ac_lto_supported=no | 1039 | ac_lto_supported=no |
| 1036 | if test $emacs_cv_clang = yes; then | 1040 | if test "$emacs_cv_clang" = yes; then |
| 1037 | AC_MSG_CHECKING([whether link-time optimization is supported by clang]) | 1041 | AC_MSG_CHECKING([whether link-time optimization is supported by clang]) |
| 1038 | GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null` | 1042 | GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null` |
| 1039 | if test -x "$GOLD_PLUGIN"; then | 1043 | if test -x "$GOLD_PLUGIN"; then |
| @@ -1062,7 +1066,7 @@ if test "${enableval}" != "no"; then | |||
| 1062 | AC_MSG_RESULT([$ac_lto_supported]) | 1066 | AC_MSG_RESULT([$ac_lto_supported]) |
| 1063 | if test "$ac_lto_supported" = "yes"; then | 1067 | if test "$ac_lto_supported" = "yes"; then |
| 1064 | CFLAGS="$CFLAGS $LTO" | 1068 | CFLAGS="$CFLAGS $LTO" |
| 1065 | if test x$emacs_cv_clang = xyes; then | 1069 | if test "$emacs_cv_clang" = yes; then |
| 1066 | AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang]) | 1070 | AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang]) |
| 1067 | # WARNING: 'ar --plugin ...' doesn't work without | 1071 | # WARNING: 'ar --plugin ...' doesn't work without |
| 1068 | # command, so plugin name is appended to ARFLAGS. | 1072 | # command, so plugin name is appended to ARFLAGS. |
diff --git a/lib/strftime.c b/lib/strftime.c index 18c899d2117..99bee4ef978 100644 --- a/lib/strftime.c +++ b/lib/strftime.c | |||
| @@ -1123,23 +1123,18 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1123 | if (modifier == L_('E')) | 1123 | if (modifier == L_('E')) |
| 1124 | goto bad_format; | 1124 | goto bad_format; |
| 1125 | 1125 | ||
| 1126 | { | 1126 | number_value = ns; |
| 1127 | /* Use a new variable here instead of reusing number_value | 1127 | if (width == -1) |
| 1128 | because Clang complains about the self-assignment | 1128 | width = 9; |
| 1129 | generated by DO_NUMBER. */ | 1129 | else |
| 1130 | ptrdiff_t n = ns; | 1130 | { |
| 1131 | if (width == -1) | 1131 | /* Take an explicit width less than 9 as a precision. */ |
| 1132 | width = 9; | 1132 | int j; |
| 1133 | else | 1133 | for (j = width; j < 9; j++) |
| 1134 | { | 1134 | number_value /= 10; |
| 1135 | /* Take an explicit width less than 9 as a precision. */ | 1135 | } |
| 1136 | int j; | ||
| 1137 | for (j = width; j < 9; j++) | ||
| 1138 | n /= 10; | ||
| 1139 | } | ||
| 1140 | 1136 | ||
| 1141 | DO_NUMBER (width, n); | 1137 | DO_NUMBER (width, number_value); |
| 1142 | } | ||
| 1143 | #endif | 1138 | #endif |
| 1144 | 1139 | ||
| 1145 | case L_('n'): | 1140 | case L_('n'): |
diff --git a/src/emacs.c b/src/emacs.c index 08430de6ca7..da8df1bf1c7 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -832,7 +832,7 @@ main (int argc, char **argv) | |||
| 832 | (https://www.cygwin.com/ml/cygwin/2015-07/msg00096.html). */ | 832 | (https://www.cygwin.com/ml/cygwin/2015-07/msg00096.html). */ |
| 833 | struct rlimit rlim; | 833 | struct rlimit rlim; |
| 834 | if (getrlimit (RLIMIT_STACK, &rlim) == 0 | 834 | if (getrlimit (RLIMIT_STACK, &rlim) == 0 |
| 835 | && rlim.rlim_cur <= LONG_MAX) | 835 | && 0 <= rlim.rlim_cur && rlim.rlim_cur <= LONG_MAX) |
| 836 | { | 836 | { |
| 837 | rlim_t lim = rlim.rlim_cur; | 837 | rlim_t lim = rlim.rlim_cur; |
| 838 | 838 | ||
| @@ -866,7 +866,7 @@ main (int argc, char **argv) | |||
| 866 | right thing anyway. */ | 866 | right thing anyway. */ |
| 867 | long pagesize = getpagesize (); | 867 | long pagesize = getpagesize (); |
| 868 | newlim += pagesize - 1; | 868 | newlim += pagesize - 1; |
| 869 | if (rlim.rlim_max < newlim) | 869 | if (0 <= rlim.rlim_max && rlim.rlim_max < newlim) |
| 870 | newlim = rlim.rlim_max; | 870 | newlim = rlim.rlim_max; |
| 871 | newlim -= newlim % pagesize; | 871 | newlim -= newlim % pagesize; |
| 872 | 872 | ||