1*4882a593SmuzhiyunFrom e64a58387db46239902b610871a0eb81626e99ff Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Paul Eggert <eggert@cs.ucla.edu> 3*4882a593SmuzhiyunDate: Thu, 18 Aug 2022 07:46:28 -0700 4*4882a593SmuzhiyunSubject: [PATCH] Turn on -pedantic-errors at the end of 'configure' 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunProblem reported by Khem Raj in: 7*4882a593Smuzhiyunhttps://lists.gnu.org/r/autoconf-patches/2022-08/msg00009.html 8*4882a593SmuzhiyunUpstream-Status: Submitted [https://lists.samba.org/archive/rsync/2022-August/032862.html] 9*4882a593Smuzhiyun--- 10*4882a593Smuzhiyun configure.ac | 35 ++++++++++++++++++++--------------- 11*4882a593Smuzhiyun 1 file changed, 20 insertions(+), 15 deletions(-) 12*4882a593Smuzhiyun 13*4882a593Smuzhiyundiff --git a/configure.ac b/configure.ac 14*4882a593Smuzhiyunindex d185b2d3..7e9514f7 100644 15*4882a593Smuzhiyun--- a/configure.ac 16*4882a593Smuzhiyun+++ b/configure.ac 17*4882a593Smuzhiyun@@ -1071,21 +1071,6 @@ elif test x"$ac_cv_header_popt_h" != x"yes"; then 18*4882a593Smuzhiyun with_included_popt=yes 19*4882a593Smuzhiyun fi 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun-if test x"$GCC" = x"yes"; then 22*4882a593Smuzhiyun- if test x"$with_included_popt" != x"yes"; then 23*4882a593Smuzhiyun- # Turn pedantic warnings into errors to ensure an array-init overflow is an error. 24*4882a593Smuzhiyun- CFLAGS="$CFLAGS -pedantic-errors" 25*4882a593Smuzhiyun- else 26*4882a593Smuzhiyun- # Our internal popt code cannot be compiled with pedantic warnings as errors, so try to 27*4882a593Smuzhiyun- # turn off pedantic warnings (which will not lose the error for array-init overflow). 28*4882a593Smuzhiyun- # Older gcc versions don't understand -Wno-pedantic, so check if --help=warnings lists 29*4882a593Smuzhiyun- # -Wpedantic and use that as a flag. 30*4882a593Smuzhiyun- case `$CC --help=warnings 2>/dev/null | grep Wpedantic` in 31*4882a593Smuzhiyun- *-Wpedantic*) CFLAGS="$CFLAGS -pedantic-errors -Wno-pedantic" ;; 32*4882a593Smuzhiyun- esac 33*4882a593Smuzhiyun- fi 34*4882a593Smuzhiyun-fi 35*4882a593Smuzhiyun- 36*4882a593Smuzhiyun AC_MSG_CHECKING([whether to use included libpopt]) 37*4882a593Smuzhiyun if test x"$with_included_popt" = x"yes"; then 38*4882a593Smuzhiyun AC_MSG_RESULT($srcdir/popt) 39*4882a593Smuzhiyun@@ -1444,6 +1429,26 @@ case "$CC" in 40*4882a593Smuzhiyun ;; 41*4882a593Smuzhiyun esac 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun+# Enable -pedantic-errors last, so that it doesn't mess up other 44*4882a593Smuzhiyun+# 'configure' tests. For example, Autoconf uses empty function 45*4882a593Smuzhiyun+# prototypes like 'int main () {}' which Clang 15's -pedantic-errors 46*4882a593Smuzhiyun+# would reject. Generally it's not a good idea to try to run 47*4882a593Smuzhiyun+# 'configure' itself with strict compiler checking. 48*4882a593Smuzhiyun+if test x"$GCC" = x"yes"; then 49*4882a593Smuzhiyun+ if test x"$with_included_popt" != x"yes"; then 50*4882a593Smuzhiyun+ # Turn pedantic warnings into errors to ensure an array-init overflow is an error. 51*4882a593Smuzhiyun+ CFLAGS="$CFLAGS -pedantic-errors" 52*4882a593Smuzhiyun+ else 53*4882a593Smuzhiyun+ # Our internal popt code cannot be compiled with pedantic warnings as errors, so try to 54*4882a593Smuzhiyun+ # turn off pedantic warnings (which will not lose the error for array-init overflow). 55*4882a593Smuzhiyun+ # Older gcc versions don't understand -Wno-pedantic, so check if --help=warnings lists 56*4882a593Smuzhiyun+ # -Wpedantic and use that as a flag. 57*4882a593Smuzhiyun+ case `$CC --help=warnings 2>/dev/null | grep Wpedantic` in 58*4882a593Smuzhiyun+ *-Wpedantic*) CFLAGS="$CFLAGS -pedantic-errors -Wno-pedantic" ;; 59*4882a593Smuzhiyun+ esac 60*4882a593Smuzhiyun+ fi 61*4882a593Smuzhiyun+fi 62*4882a593Smuzhiyun+ 63*4882a593Smuzhiyun AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig]) 64*4882a593Smuzhiyun AC_OUTPUT 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun-- 67*4882a593Smuzhiyun2.37.1 68*4882a593Smuzhiyun 69