From cdd0de4b056b4612e055fa15f65af118dafc9b18 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 16 May 2013 00:10:39 -0700 Subject: [PATCH] Merge from gnulib. 2013-05-15 manywarnings: update for GCC 4.8.0 2013-05-15 stdio: use __REDIRECT for fwrite, fwrite_unlocked 2013-05-15 sig2str, stdio, warnings: port to clang --- ChangeLog | 7 +++++++ lib/sig2str.c | 12 ++++++++---- lib/stdio.in.h | 14 ++++++++++++-- m4/manywarnings.m4 | 6 ++---- m4/warnings.m4 | 15 ++++++++++++--- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8b46164388..ce2014288e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-05-16 Paul Eggert + + Merge from gnulib, incorporating: + 2013-05-15 manywarnings: update for GCC 4.8.0 + 2013-05-15 stdio: use __REDIRECT for fwrite, fwrite_unlocked + 2013-05-15 sig2str, stdio, warnings: port to clang + 2013-05-15 Stefan Monnier * Makefile.in (install-doc): DOC file is not version specific any more. diff --git a/lib/sig2str.c b/lib/sig2str.c index 8b36e2facf0..6ead2a71d13 100644 --- a/lib/sig2str.c +++ b/lib/sig2str.c @@ -325,21 +325,25 @@ sig2str (int signum, char *signame) { int rtmin = SIGRTMIN; int rtmax = SIGRTMAX; + int base, delta; if (! (rtmin <= signum && signum <= rtmax)) return -1; if (signum <= rtmin + (rtmax - rtmin) / 2) { - int delta = signum - rtmin; - sprintf (signame, delta ? "RTMIN+%d" : "RTMIN", delta); + strcpy (signame, "RTMIN"); + base = rtmin; } else { - int delta = rtmax - signum; - sprintf (signame, delta ? "RTMAX-%d" : "RTMAX", delta); + strcpy (signame, "RTMAX"); + base = rtmax; } + delta = signum - base; + if (delta != 0) + sprintf (signame + 5, "%+d", delta); return 0; } } diff --git a/lib/stdio.in.h b/lib/stdio.in.h index d6af99ca77d..06cbad00d3d 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -579,13 +579,23 @@ _GL_CXXALIAS_SYS (fwrite, size_t, , which sometimes causes an unwanted diagnostic for fwrite calls. This affects only function declaration attributes under certain - versions of gcc, and is not needed for C++. */ + versions of gcc and clang, and is not needed for C++. */ # if (0 < __USE_FORTIFY_LEVEL \ && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ && !defined __cplusplus) # undef fwrite -# define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; }) +# undef fwrite_unlocked +extern size_t __REDIRECT (rpl_fwrite, + (const void *__restrict, size_t, size_t, + FILE *__restrict), + fwrite); +extern size_t __REDIRECT (rpl_fwrite_unlocked, + (const void *__restrict, size_t, size_t, + FILE *__restrict), + fwrite_unlocked); +# define fwrite rpl_fwrite +# define fwrite_unlocked rpl_fwrite_unlocked # endif # endif _GL_CXXALIASWARN (fwrite); diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 45a30afda70..be6d4c91c50 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -98,6 +98,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], -W \ -Wabi \ -Waddress \ + -Waggressive-loop-optimizations \ -Wall \ -Warray-bounds \ -Wattributes \ @@ -125,7 +126,6 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], -Wformat-security \ -Wformat-y2k \ -Wformat-zero-length \ - -Wformat=2 \ -Wfree-nonheap-object \ -Wignored-qualifiers \ -Wimplicit \ @@ -143,9 +143,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], -Wmissing-braces \ -Wmissing-declarations \ -Wmissing-field-initializers \ - -Wmissing-format-attribute \ -Wmissing-include-dirs \ - -Wmissing-noreturn \ -Wmissing-parameter-type \ -Wmissing-prototypes \ -Wmudflap \ @@ -166,6 +164,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], -Wpointer-sign \ -Wpointer-to-int-cast \ -Wpragmas \ + -Wreturn-local-addr \ -Wreturn-type \ -Wsequence-point \ -Wshadow \ @@ -187,7 +186,6 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], -Wtype-limits \ -Wuninitialized \ -Wunknown-pragmas \ - -Wunreachable-code \ -Wunsafe-loop-optimizations \ -Wunused \ -Wunused-but-set-parameter \ diff --git a/m4/warnings.m4 b/m4/warnings.m4 index 4b2ac385019..184873283bb 100644 --- a/m4/warnings.m4 +++ b/m4/warnings.m4 @@ -1,4 +1,4 @@ -# warnings.m4 serial 7 +# warnings.m4 serial 8 dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -27,7 +27,7 @@ AC_DEFUN([gl_COMPILER_OPTION_IF], AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [ gl_save_compiler_FLAGS="$gl_Flags" - gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $1"]) + gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $gl_unknown_warnings_are_errors $1"]) AC_COMPILE_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])], [AS_VAR_SET(gl_Warn, [yes])], [AS_VAR_SET(gl_Warn, [no])]) @@ -38,6 +38,14 @@ AS_VAR_POPDEF([gl_Flags])dnl AS_VAR_POPDEF([gl_Warn])dnl ]) +# gl_UNKNOWN_WARNINGS_ARE_ERRORS +# ------------------------------ +# Clang doesn't complain about unknown warning options unless one also +# specifies -Wunknown-warning-option -Werror. Detect this. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], +[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option], + [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'], + [gl_unknown_warnings_are_errors=])]) # gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS], # [PROGRAM = AC_LANG_PROGRAM()]) @@ -47,7 +55,8 @@ AS_VAR_POPDEF([gl_Warn])dnl # # If VARIABLE is a variable name, AC_SUBST it. AC_DEFUN([gl_WARN_ADD], -[gl_COMPILER_OPTION_IF([$1], +[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) +gl_COMPILER_OPTION_IF([$1], [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])], [], [$3]) -- 2.39.2