]> 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>
Mon, 26 Aug 2024 22:19:14 +0000 (00:19 +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/savedir.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.

28 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/savedir.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 80e771c304273851d0ebf0e102ddbd9328b7b390..0dadf61ea0b3b317ae6665fc94837fac35f470ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+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/savedir.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>
 
        relocatable-prog: Fix config.libpath failure (regression 2024-08-24).
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 f86ac4f7eed2eec4791a6689ac5dd19be680306c..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 4 <= __GNUC__ + (7 <= __GNUC_MINOR__)
+#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 80049ca1def46d7bfc712dcca862d96efb9ff74b..a902635f2cc59d7b6076745b5eb8bf774b3cb84c 100644 (file)
@@ -39,7 +39,7 @@
 #include "xalloc.h"
 
 /* Pacify GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113963>.  */
-#if 13 <= __GNUC__
+#if _GL_GNUC_PREREQ (13, 0)
 # pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
 # pragma GCC diagnostic ignored "-Wanalyzer-null-dereference"
 #endif
index 67277d5ffe94d33e8cdad233f138f5d99562aa40..9ace64b5beac1133b1902eaa33e6def79ef8ad8a 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 8efb9ebee2a6cb6f217d1e2bd2250529a5b7b7b4..6ae95ca5dd22f666481e6e967a79b30a91123fb2 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
 
@@ -968,7 +968,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
@@ -1029,7 +1029,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 d8f6d09733fdc45410d093182b0f5caf5adc72da..6128b7f89e091b22fdf9e3fb72f51bfd5c0ff825 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 be1e022a0abf66f116ee1de188aec6893602c17a..464478529fdbc874ba8d699d85b45b210e70f2e2 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 1c0fd8e6e2d5aca9c18907183eb46bceeae6a34a..4f576da7c3c3d58cb01fa91db94fcc2b79a2d71c 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 933df99ab6f53c89dca6b39561fc53afabcd5750..66ab9ccb47ed43f38e2800272c2e4a9cc02c791b 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 e826c634a93005a1723739fa44a5cb04bc0b070a..614be06d9811240247720ba810e895c7de50d815 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 7a99c012d89180c2e88619ecf6a24a98f17d392e..6cdd8630bd48a32825683ec7a173e85e6a3d6ef6 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 6ccffaa1d945a7f306b14475b8e58e2d9e259043..b7ce9b435ce25ef7ae58a017574c596e38639d4d 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 0e64ce6a949180feebebd05a975054eaf76dde7a..beb976ac5a0c7be7f99747ad53a58084e71656f1 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 e7ac64147cb8da724ebe4db87d7a8ee9addd1016..477415b45f68096ce3050995e8f7d2e338d38c4f 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 5fe25d69fde0fa188315cb3092981d37c82fdc23..295949157d6f7b1d282de13d5552da2336bfdc17 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