]> Savannah Git Hosting - gnulib.git/commitdiff
Fix some of the warnings from a clang that masquerades as gcc 13.
authorBruno Haible <bruno@clisp.org>
Mon, 26 Aug 2024 22:19:14 +0000 (00:19 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 17 Sep 2024 13:13:59 +0000 (15:13 +0200)
* lib/c-stack.c: Use _GL_GNUC_PREREQ to test for the gcc version.
* lib/canonicalize.c: Likewise.
* lib/diffseq.h: Likewise.
* lib/file-has-acl.c: Likewise.
* lib/freopen-safer.c: Likewise.
* lib/getndelim2.c: Likewise.
* lib/mini-gmp-gnulib.c: Likewise.
* lib/propername.c: Likewise.
* lib/quotearg.c: Likewise.
* lib/vasnprintf.c: Likewise.
* tests/test-argmatch.c: Likewise.
* tests/test-dup2.c: Likewise.
* tests/test-explicit_bzero.c: Likewise.
* tests/test-fcntl.c: Likewise.
* tests/test-fopen.h: Likewise.
* tests/test-getdtablesize.c: Likewise.
* tests/test-getgroups.c: Likewise.
* tests/test-listen.c: Likewise.
* tests/test-localename.c: Likewise.
* tests/test-memset_explicit.c: Likewise.
* tests/test-open.h: Likewise.
* tests/test-perror2.c: Likewise.
* tests/test-select.h: Likewise.
* lib/stdio.in.h (_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD): Don't use
gnu_printf with clang.
* lib/string-buffer.h: Likewise.
* lib/textstyle.in.h: Likewise.

27 files changed:
ChangeLog
lib/c-stack.c
lib/canonicalize.c
lib/diffseq.h
lib/file-has-acl.c
lib/freopen-safer.c
lib/getndelim2.c
lib/mini-gmp-gnulib.c
lib/propername.c
lib/quotearg.c
lib/stdio.in.h
lib/string-buffer.h
lib/textstyle.in.h
lib/vasnprintf.c
tests/test-argmatch.c
tests/test-dup2.c
tests/test-explicit_bzero.c
tests/test-fcntl.c
tests/test-fopen.h
tests/test-getdtablesize.c
tests/test-getgroups.c
tests/test-listen.c
tests/test-localename.c
tests/test-memset_explicit.c
tests/test-open.h
tests/test-perror2.c
tests/test-select.h

index 9708e56cfbdd052102cda7b54bc2cd3eb176cff1..2ce32974eccb4afa9e8e95615351c4ddab63cf8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2024-08-26  Bruno Haible  <bruno@clisp.org>
+
+       Fix some of the warnings from a clang that masquerades as gcc 13.
+       * lib/c-stack.c: Use _GL_GNUC_PREREQ to test for the gcc version.
+       * lib/canonicalize.c: Likewise.
+       * lib/diffseq.h: Likewise.
+       * lib/file-has-acl.c: Likewise.
+       * lib/freopen-safer.c: Likewise.
+       * lib/getndelim2.c: Likewise.
+       * lib/mini-gmp-gnulib.c: Likewise.
+       * lib/propername.c: Likewise.
+       * lib/quotearg.c: Likewise.
+       * lib/vasnprintf.c: Likewise.
+       * tests/test-argmatch.c: Likewise.
+       * tests/test-dup2.c: Likewise.
+       * tests/test-explicit_bzero.c: Likewise.
+       * tests/test-fcntl.c: Likewise.
+       * tests/test-fopen.h: Likewise.
+       * tests/test-getdtablesize.c: Likewise.
+       * tests/test-getgroups.c: Likewise.
+       * tests/test-listen.c: Likewise.
+       * tests/test-localename.c: Likewise.
+       * tests/test-memset_explicit.c: Likewise.
+       * tests/test-open.h: Likewise.
+       * tests/test-perror2.c: Likewise.
+       * tests/test-select.h: Likewise.
+       * lib/stdio.in.h (_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD): Don't use
+       gnu_printf with clang.
+       * lib/string-buffer.h: Likewise.
+       * lib/textstyle.in.h: Likewise.
+
 2024-08-26  Bruno Haible  <bruno@clisp.org>
 
        Fix compilation errors with clang that masquerades as gcc 13.
index b8974d3489191a87f1a856a2dd86b41d0befd461..0e14de94230dc6a6adbb2706f0d62352baa579ff 100644 (file)
@@ -130,7 +130,7 @@ null_action (_GL_UNUSED int signo)
 }
 
 /* Pacify GCC 9.3.1, which otherwise would complain about segv_handler.  */
-# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+# if _GL_GNUC_PREREQ (4, 6)
 #  pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
 # endif
 
index 52e9b3b371cc637c365bac1ac9f15a4dd1ce3054..7d2a629024b18adde01a5c9c9aa3de2c169ab878 100644 (file)
@@ -45,7 +45,7 @@
 #endif
 
 /* Avoid false GCC warning "'end_idx' may be used uninitialized".  */
-#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4
+#if _GL_GNUC_PREREQ (4, 7)
 # pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #endif
 
index 362df177afc12a385c16aefd50998f8ea33711d3..c9369e44100ffa112bff0fbd6c2c2f15c87de519 100644 (file)
 /* Suppress gcc's "...may be used before initialized" warnings,
    generated by GCC versions up to at least GCC 14.2.
    Likewise for gcc -fanalyzer's "use of uninitialized value" warnings.  */
-#if 4 <= __GNUC__ + (7 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 7)
 # pragma GCC diagnostic push
 # pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-# if 13 <= __GNUC__
+# if _GL_GNUC_PREREQ (13, 0)
 #  pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value"
 # endif
 #endif
@@ -558,7 +558,7 @@ compareseq (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim,
   #undef XREF_YREF_EQUAL
 }
 
-#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4
+#if _GL_GNUC_PREREQ (4, 7)
 # pragma GCC diagnostic pop
 #endif
 
index 898fb030d1de9b9f6e886e099f29c98b31310c58..06759a4948c1dea0648cc04c7ca9b052538fd110 100644 (file)
 
    Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible.  */
 
+#include <config.h>
+
 /* Without this pragma, gcc 4.7.0 20120126 may suggest that the
    file_has_acl function might be candidate for attribute 'const'  */
-#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+#if _GL_GNUC_PREREQ (4, 6)
 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
 #endif
 
-#include <config.h>
-
 #include "acl.h"
 
 #include "acl-internal.h"
index 3a7f5681149c71678076b1e6e65316d1b8a08714..14cb5fcbee6fdced95941c8e1c09f534a06b0057 100644 (file)
@@ -28,7 +28,7 @@
 #include <unistd.h>
 
 /* GCC 13 misunderstands the dup2 trickery in this file.  */
-#if 13 <= __GNUC__
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-leak"
 #endif
 
index dc11f8dd21372f9b19f24da64b9aaf929fbf74fb..89989aefdd5ea3fa78f2bbad1575a9052207cc88 100644 (file)
@@ -47,7 +47,7 @@
 #include "memchr2.h"
 
 /* Avoid false GCC warning "'c' may be used uninitialized".  */
-#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4
+#if _GL_GNUC_PREREQ (4, 7)
 # pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #endif
 
index 6e02d3cefb6903e0c83f89b7bb0a200236259907..764323f8f7869b903c265c9496cc456b74fe556b 100644 (file)
 #include "mini-gmp.h"
 
 /* Pacify GCC -Wsuggest-attribute=const, pure, malloc.  */
-#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+#if _GL_GNUC_PREREQ (4, 6)
 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
 # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
 #endif
-#if 8 <= __GNUC__
+#if _GL_GNUC_PREREQ (8, 0)
 # pragma GCC diagnostic ignored "-Wsuggest-attribute=malloc"
 #endif
 
index 7e072d35b689370acc305547b3e28167cfd0753c..602ff093bb5c31fe819cd7d4ca05ce0028cb2fd6 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
+#include <config.h>
+
 /* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that
    the proper_name function might be candidate for attribute 'const'  */
-#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+#if _GL_GNUC_PREREQ (4, 6)
 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
 #endif
 
-#include <config.h>
-
 /* Specification.  */
 #include "propername.h"
 
index 5ca511a4924717900fe24dc73a7fec4af454a04b..8e359beead7b6ce96bb2ef084bd55b0696b6f6f8 100644 (file)
 
 /* Written by Paul Eggert <eggert@twinsun.com> */
 
+#include <config.h>
+
 /* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that
    the quoting_options_from_style function might be candidate for
    attribute 'pure'  */
-#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+#if _GL_GNUC_PREREQ (4, 6)
 # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
 #endif
 
-#include <config.h>
-
 #include "quotearg.h"
 #include "quote.h"
 
index 99c9baf831a85d6f1321d235eb257284a066b7c8..55bcb41d0ff1ea9289926f9280540a8ecc51a653 100644 (file)
    standardized by ISO C99 and POSIX.
    _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD  */
 /* __gnu_printf__ is supported in GCC >= 4.4.  */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
 # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
 #else
 # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
index 75fd7cbef8104528d0d7603440c2df95ce2f6bc2..c854aaa809d3744d8018dbb7cd864c0782396239 100644 (file)
@@ -55,7 +55,7 @@ extern int sb_append (struct string_buffer *buffer, const char *str);
    Returns 0, or -1 in case of error.  */
 extern int sb_appendvf (struct string_buffer *buffer,
                         const char *formatstring, va_list list)
-  #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+  #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
   ATTRIBUTE_FORMAT ((__gnu_printf__, 2, 0))
   #else
   ATTRIBUTE_FORMAT ((__printf__, 2, 0))
@@ -67,7 +67,7 @@ extern int sb_appendvf (struct string_buffer *buffer,
    Returns 0, or -1 in case of error.  */
 extern int sb_appendf (struct string_buffer *buffer,
                         const char *formatstring, ...)
-  #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+  #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
   ATTRIBUTE_FORMAT ((__gnu_printf__, 2, 3))
   #else
   ATTRIBUTE_FORMAT ((__printf__, 2, 3))
index 3cbd5c04c3dd21495b82b3e01119bfde4e0404dd..39eab0576e7e3e7ed03daa24d140ef821168f218 100644 (file)
@@ -52,7 +52,7 @@
    _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD  */
 /* __gnu_printf__ is supported in GCC >= 4.4.  */
 #ifndef _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
 #  define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
 # else
 #  define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
index b7950a5612237d5f4bdffb3dacdf72f38f7cf028..a31cdf5eccb2f3975e8090d2ad6984cfd73f86fb 100644 (file)
@@ -64,7 +64,7 @@
 /* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's
    use of CHECK macros expands to code that is too complicated for gcc
    -fanalyzer.  Suppress the resulting bogus warnings.  */
-#if 10 <= __GNUC__
+#if _GL_GNUC_PREREQ (10, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
 #endif
 
@@ -964,7 +964,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
 /* Avoid pointless GCC warning "argument 1 value '18446744073709551615' exceeds
    maximum object size 9223372036854775807", triggered by the use of xsum as
    argument of malloc.  */
-# if __GNUC__ >= 7
+# if _GL_GNUC_PREREQ (7, 0)
 #  pragma GCC diagnostic push
 #  pragma GCC diagnostic ignored "-Walloc-size-larger-than="
 # endif
@@ -1025,7 +1025,7 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
   return c_ptr;
 }
 
-# if __GNUC__ >= 7
+# if _GL_GNUC_PREREQ (7, 0)
 #  pragma GCC diagnostic pop
 # endif
 
index 2c18077fc304aef8d7c1982de5dba32eed1eede5..1df2614ef306d0da696eba11bd2361a713d3e48c 100644 (file)
@@ -22,7 +22,7 @@
 /* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's
    use of CHECK macros expands to code that is too complicated for gcc
    -fanalyzer.  Suppress the resulting bogus warnings.  */
-#if 10 <= __GNUC__
+#if _GL_GNUC_PREREQ (10, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
 #endif
 
index 55f3194023ac4022fffd3ff6daa417ebc2cc4b92..31cf0016da2ebaa8522fe67fe964ba33879912d9 100644 (file)
@@ -51,7 +51,7 @@ SIGNATURE_CHECK (dup2, int, (int, int));
 #include "macros.h"
 
 /* Tell GCC not to warn about the specific edge cases tested here.  */
-#if __GNUC__ >= 13
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-leak"
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check"
 #endif
index b4c98b665229b748114066667a16c0d728731d6c..6ef7f92d8c22cf03a9e867e69c069889038a8582 100644 (file)
@@ -42,7 +42,7 @@ static char zero[SECRET_SIZE] = { 0 };
 #endif
 
 /* Suppress GCC 13.2.1 false alarm, as this test needs a dangling pointer.  */
-#if 12 <= __GNUC__
+#if _GL_GNUC_PREREQ (12, 0)
 # pragma GCC diagnostic ignored "-Wdangling-pointer"
 #endif
 
@@ -168,10 +168,10 @@ test_stack (void)
    does not eliminate a call to explicit_bzero, even if data flow analysis
    reveals that the stack area is dead at the end of the function.  */
 static bool _GL_ATTRIBUTE_NOINLINE
-# if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
+# if _GL_GNUC_PREREQ (4, 5)
 __attribute__ ((__noclone__))
 # endif
-# if __GNUC__ >= 8
+# if _GL_GNUC_PREREQ (8, 0)
 __attribute__ ((__noipa__))
 # endif
 do_secret_stuff (int volatile pass, char *volatile *volatile last_stackbuf)
index 0eb24a9f6af37232846dd11bfebb94f95045ee46..4101fc402eb46bbbebe900c52e177bb4a4210260 100644 (file)
@@ -45,7 +45,7 @@ SIGNATURE_CHECK (fcntl, int, (int, int, ...));
 #include "macros.h"
 
 /* Tell GCC not to warn about the specific edge cases tested here.  */
-#if __GNUC__ >= 13
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-leak"
 # pragma GCC diagnostic ignored "-Wanalyzer-va-arg-type-mismatch"
 #endif
index 526736222495b7ea1dea7813751c21acf736f28c..5fdb6f94a3028610dce1ca420ecce59623609c1a 100644 (file)
@@ -24,7 +24,7 @@
 #include "macros.h"
 
 /* Tell GCC not to warn about the specific edge cases tested here.  */
-#if __GNUC__ >= 10
+#if _GL_GNUC_PREREQ (10, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-file-leak"
 #endif
 
index 401fe9011ae8d00d49e8b42e8e85c81d59bda6a9..7f12a4f20847cc7c89ce886d800277f322c82db3 100644 (file)
@@ -26,7 +26,7 @@ SIGNATURE_CHECK (getdtablesize, int, (void));
 #include "macros.h"
 
 /* Tell GCC not to warn about the specific edge cases tested here.  */
-#if __GNUC__ >= 13
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-leak"
 #endif
 
index 45d01a32372e9161b0e0a4322bdbc2a13678c46f..c296d2912c5ee31365a2dd68b8db9b5568a55063 100644 (file)
@@ -35,7 +35,7 @@ SIGNATURE_CHECK (getgroups, int, (int, gid_t[]));
    any -W options, because getgroups() is declared with
      __attribute__ ((__access__ (__write_only__, 2, 1)))
  */
-#if __GNUC__ >= 7
+#if _GL_GNUC_PREREQ (7, 0)
 # pragma GCC diagnostic ignored "-Wstringop-overflow"
 #endif
 
index 21fc7a2b3e84cda10ce7ff3ad9b064fbffd8b318..941f76371dbe0a7f1b16f34a69454a2f855e5d0e 100644 (file)
@@ -28,7 +28,7 @@ SIGNATURE_CHECK (listen, int, (int, int));
 #include "macros.h"
 
 /* Tell GCC not to warn about the specific edge cases tested here.  */
-#if __GNUC__ >= 13
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check"
 #endif
 
index fe31201361e2e34167fe6082260e8a795eec919d..7aa508b66d0b0aa916b09d95b3cefc4229ca006c 100644 (file)
@@ -36,7 +36,7 @@
 #endif
 
 /* Suppress GCC false positive.  */
-#if __GNUC__ >= 12
+#if _GL_GNUC_PREREQ (12, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value"
 #endif
 
index f3da4a775b152179627fd7cde82449700861b060..0883017fea21c81e06b33b6040bca59067a88fa2 100644 (file)
@@ -44,7 +44,7 @@ static char zero[SECRET_SIZE] = { 0 };
 #endif
 
 /* Suppress GCC 13.2.1 false alarm, as this test needs a dangling pointer.  */
-#if 12 <= __GNUC__
+#if _GL_GNUC_PREREQ (12, 0)
 # pragma GCC diagnostic ignored "-Wdangling-pointer"
 #endif
 
@@ -178,10 +178,10 @@ test_stack (void)
    does not eliminate a call to memset_explicit, even if data flow analysis
    reveals that the stack area is dead at the end of the function.  */
 static bool _GL_ATTRIBUTE_NOINLINE
-# if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
+# if _GL_GNUC_PREREQ (4, 5)
 __attribute__ ((__noclone__))
 # endif
-# if __GNUC__ >= 8
+# if _GL_GNUC_PREREQ (8, 0)
 __attribute__ ((__noipa__))
 # endif
 do_secret_stuff (int volatile pass, char *volatile *volatile last_stackbuf)
index 05764356f832bdc2699707d99b4554ea86d4bf2a..369c926fcf065f74463d752b0614ceb6fa016d8a 100644 (file)
@@ -17,7 +17,7 @@
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
 /* Tell GCC not to warn about the specific edge cases tested here.  */
-#if __GNUC__ >= 13
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-leak"
 #endif
 
index edf1d15f9f9c143d2e236db13c79b8d8b4a876bc..b51449aa70cfbc22c654ecdab588ae712e43d0f3 100644 (file)
@@ -23,7 +23,7 @@
 #include <unistd.h>
 
 /* Tell GCC not to warn about myerr being leaked.  */
-#if __GNUC__ >= 13
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-leak"
 #endif
 
index 4896b674967a6ebf86a4916a9c4d2aa13d6b4263..74a91c4b938d866e56c4c6bd3d9747676a4d5adf 100644 (file)
@@ -38,7 +38,7 @@
 #endif
 
 /* Tell GCC not to warn about the specific edge cases tested here.  */
-#if __GNUC__ >= 13
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check"
 #endif