* 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 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.
}
/* 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
#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
/* 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
#undef XREF_YREF_EQUAL
}
-#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4
+#if _GL_GNUC_PREREQ (4, 7)
# pragma GCC diagnostic pop
#endif
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"
#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
#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
#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
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"
/* 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"
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__
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))
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))
_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__
/* 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
/* 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
return c_ptr;
}
-# if __GNUC__ >= 7
+# if _GL_GNUC_PREREQ (7, 0)
# pragma GCC diagnostic pop
# endif
/* 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
#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
#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
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)
#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
#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
#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
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
#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
#endif
/* Suppress GCC false positive. */
-#if __GNUC__ >= 12
+#if _GL_GNUC_PREREQ (12, 0)
# pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value"
#endif
#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
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)
/* 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
#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
#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