stdio: port --enable-gcc-warnings to clang
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 15 May 2013 07:30:43 +0000 (00:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 15 May 2013 07:33:39 +0000 (00:33 -0700)
* lib/stdio.in.h (fwrite) [__clang__]: Ignore -Wunused-value entirely,
since the GCC workaround for fwrite does not pacify clang.

ChangeLog
lib/stdio.in.h

index baa594e..dfb2e5c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-05-15  Paul Eggert  <eggert@cs.ucla.edu>
 
+       stdio: port --enable-gcc-warnings to clang
+       * lib/stdio.in.h (fwrite) [__clang__]: Ignore -Wunused-value entirely,
+       since the GCC workaround for fwrite does not pacify clang.
+
        sig2str: port --enable-gcc-warnings to clang
        * lib/sig2str.c (sig2str): Avoid warning about unused printf argument.
 
index c345499..115c976 100644 (file)
@@ -579,13 +579,16 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
    <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
    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; })
+#   ifdef __clang__
+#    pragma clang diagnostic ignored "-Wunused-value"
+#   elif 3 < __GNUC__ + (4 <= __GNUC_MINOR__)
+#    undef fwrite
+#    define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; })
+#   endif
 #  endif
 # endif
 _GL_CXXALIASWARN (fwrite);