On 2023-09-21 13:21, Pádraig Brady wrote:
I was trying to use -Wpedantic to check for standards conformance,
where some code compilable on gcc 13 by default, is no longer compilable
on gcc <= 10.
Like Bruno, I've not had much luck with -Wpedantic for doing that. The
GCC manual even has qualms about it.
ever since commit:
https://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=4f6131a786
if the user specifies --Wpedantic, then it's ignored
(and that's not at all obvious as there are early warnings before the pragma).
I tried to work around that problem by installing the attached patch.
Please give it a try. Even if -Wpedantic has problems, it's better if
Gnulib doesn't override the builder unnecessarily.
From 18bf1bf18be99e59624f039220feb19355fe239f Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 21 Sep 2023 14:26:24 -0700
Subject: [PATCH] =?UTF-8?q?gnulib-common:=20don=E2=80=99t=20suppress=20-Wp?=
=?UTF-8?q?edantic?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Pádraig Brady in:
https://lists.gnu.org/r/bug-gnulib/2023-09/msg00130.html
* m4/gnulib-common.m4 (_GL_HAVE___HAS_C_ATTRIBUTE): New macro.
Use it instead of ‘defined __has_c_attribute’.
---
ChangeLog | 6 ++++++
m4/gnulib-common.m4 | 22 +++++++++++++---------
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 65315fc973..160332c116 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2023-09-21 Paul Eggert <egg...@cs.ucla.edu>
+ gnulib-common: don’t suppress -Wpedantic
+ Problem reported by Pádraig Brady in:
+ https://lists.gnu.org/r/bug-gnulib/2023-09/msg00130.html
+ * m4/gnulib-common.m4 (_GL_HAVE___HAS_C_ATTRIBUTE): New macro.
+ Use it instead of ‘defined __has_c_attribute’.
+
crypto/sm3: rename gl_cv_* variable for clarity
* m4/gc-sm3.m4 (gl_cv_libgcrypt_md_sm3):
Rename from gl_cv_libcrypt_md_sm3 since this is unrelated to libcrypt.
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index c372316135..b3852a595e 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 88
+# gnulib-common.m4 serial 89
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -114,10 +114,14 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
#endif
-/* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */
-#if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \
- && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)
-# pragma GCC diagnostic ignored "-Wpedantic"
+/* Use __has_c_attribute if available. However, do not use with
+ pre-C23 GCC, which can issue false positives if -Wpedantic. */
+#if (defined __has_c_attribute \
+ && ! (_GL_GNUC_PREREQ (4, 6) \
+ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710))
+# define _GL_HAVE___HAS_C_ATTRIBUTE 1
+#else
+# define _GL_HAVE___HAS_C_ATTRIBUTE 0
#endif
/* Define if, in a function declaration, the attributes in bracket syntax
@@ -242,7 +246,7 @@ AC_DEFUN([gl_COMMON_BODY], [
in C++ also: namespace, class, template specialization. */
#ifndef _GL_ATTRIBUTE_DEPRECATED
# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
-# ifdef __has_c_attribute
+# if _GL_HAVE___HAS_C_ATTRIBUTE
# if __has_c_attribute (__deprecated__)
# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
# endif
@@ -291,7 +295,7 @@ AC_DEFUN([gl_COMMON_BODY], [
/* Applies to: Empty statement (;), inside a 'switch' statement. */
/* Always expands to something. */
#ifndef _GL_ATTRIBUTE_FALLTHROUGH
-# ifdef __has_c_attribute
+# if _GL_HAVE___HAS_C_ATTRIBUTE
# if __has_c_attribute (__fallthrough__)
# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
# endif
@@ -380,7 +384,7 @@ AC_DEFUN([gl_COMMON_BODY], [
# if !defined __apple_build_version__ && __clang_major__ >= 10
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
# endif
-# elif defined __has_c_attribute
+# elif _GL_HAVE___HAS_C_ATTRIBUTE
# if __has_c_attribute (__maybe_unused__)
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
# endif
@@ -411,7 +415,7 @@ AC_DEFUN([gl_COMMON_BODY], [
# if __clang_major__ >= 1000
# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
# endif
-# elif defined __has_c_attribute
+# elif _GL_HAVE___HAS_C_ATTRIBUTE
# if __has_c_attribute (__nodiscard__)
# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
# endif
--
2.39.2