From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 8A1321F5AE for ; Thu, 10 Jun 2021 19:39:49 +0000 (UTC) Received: from localhost ([::1]:40920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrQWq-0000k1-5W for normalperson@yhbt.net; Thu, 10 Jun 2021 15:39:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrQWj-0000hC-5i for bug-gnulib@gnu.org; Thu, 10 Jun 2021 15:39:41 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.161]:35199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrQWg-0008QA-3q for bug-gnulib@gnu.org; Thu, 10 Jun 2021 15:39:40 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1623353974; cv=none; d=strato.com; s=strato-dkim-0002; b=nN0yXGCF4dZE7DZxGVzM8+PlmPWR/wK9/3xbQckrifcSWc0iUMSslIyjnPKTaHwK10 9/Bm6NEFzO65TlzfTXX+vF480xSJxLWzdL3ZrziCGu4hvaUvVGwck5GGUx1OXPkyxzYm un4KiFa1W9Yif0HSGiBFuS/ZxpJt6RCwtsk2gPDhLCMYZOpkw+407gsyVnFAAKci1VYr H23L5sw6mtW0X5n40SriesoZCewqJZWPVIl+LD9FcFHDE/UjNTJ+JX6pvIpaqns8FPPr +bpnJxZfHNyFDdLNjI6xV3MFRr5U348skkpHL5woWQfbwRCrGv0ii/mPKKl5gFnWLGHO qpHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1623353974; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=hLchIh/EXxXRrV/6SCwm45TI2AADhAR01O3002fNuCE=; b=ZJSfcM9wlYdK65JTzf6Gh1Xq50OTzW3jhteaAEcsxXdSW/7RAdOUMixApd+T/IW+EO LIKsPo9J3tBzSOmA5pU2pzyjWV+A19SFwbE5iyCEP4ge39vKzPN0UIIABGSzgWrrDaXF GYgbuh3G9r+iZp+jCiUE6IrmVteXB1rdK8Po+upBiLIEgFc908JJorP+rBiv8TtlwbC3 mUpHlI3IPX/tfR0SFlChzpydiv20WZdQwafz3X79wOtOjffmOfQYoWVFTNvwbmAI7OTz UrTIZ4Y6dG7TjPnINefrRdPWSluZ6tDETgaa7jyLhu4+6nHzU2KPJeXh8RDgpXL+2E9V 4RoQ== ARC-Authentication-Results: i=1; strato.com; dkim=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1623353974; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=hLchIh/EXxXRrV/6SCwm45TI2AADhAR01O3002fNuCE=; b=fSYlPhPjIraJUbbBDXCVl1gnZH5WOc/qTXpvs/hY1VquAQDl12Vi4W2HAoxQWKW8iw rzz0ZjvoF2kdof+U7BSIeewNoJh1vKUVWR748ellP9cLd9FaaB7aaFMbWWG56jmwUzGs uwRccVZF9cV0jwxMxaAIrrh/YznpfrOvQZjC2VazWpKxmr3qhFob0wZvc2vmdV4bIeoD /PGq+qv2IcJZwa9S9LBpLbzX4l9g7Lj/4pixR2XGmnuK9ZjuTwNdBgQi944iPEc0jZDf sceptOC/JBgaVD5RM3hVBc7IVVrJWvKIGz5JhvCmpx13zcIq6CxiqXn+PRmC0zB0BYaH XKcA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqf3z5NW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.27.2 DYNA|AUTH) with ESMTPSA id q0869dx5AJdXiyv (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Thu, 10 Jun 2021 21:39:33 +0200 (CEST) From: Bruno Haible To: Paul Eggert Subject: Re: warnings in unit tests Date: Thu, 10 Jun 2021 21:39:32 +0200 Message-ID: <2531743.PxXWdyhe4H@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <948c6b04-883b-0385-0cd1-77be21b3becd@cs.ucla.edu> References: <15897619.AQZsorJ5YP@omega> <4537093.ULRrrf3QbG@omega> <948c6b04-883b-0385-0cd1-77be21b3becd@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Received-SPF: none client-ip=81.169.146.161; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: noloader@gmail.com, bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Paul Eggert wrote: > For what it's worth I'm more with Bruno on this. For the tests, the cost= =20 > of these warnings outweighs the benefit. >=20 > It'd be OK with me to disable the troublesome warnings globally for the=20 > tests subdirectory, using -Wno-missing-prototypes or whatever. Thanks for your backing, Paul. It's not the actual warnings that I want to disable. It's more the expectation that the Gnulib tests "should be warning-free" that is to be corrected. Implemented through this: 1) Add a '-Wno-error' option that disables the '-Werror' from [1] that has no raison d'=EAtre. 2) A message that indicates that warnings can be ignored in this directory. [1] https://git.savannah.gnu.org/gitweb/?p=3Dgrep.git;a=3Dblob;f=3Dgnulib-t= ests/Makefile.am;h=3D3085f6357b7ece8e68c93650bf409a7609079d19;hb=3DHEAD 2021-06-10 Bruno Haible Clarify that compiler warnings in the Gnulib tests can be ignored. * gnulib-tool (func_emit_tests_Makefile_am): Emit overrides for CFLAGS and CXXFLAGS. Emit a dependency of 'all' on 'all-notice' that prints a notice. (func_emit_initmacro_start): Add a second argument. If it is true, emit code to require gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS. (func_import, func_create_testdir): All callers updated. * m4/gnulib-common.m4 (gl_CC_ALLOW_WARNINGS, gl_CXX_ALLOW_WARNINGS): New macros. diff --git a/gnulib-tool b/gnulib-tool index 237693a..d41d58c 100755 =2D-- a/gnulib-tool +++ b/gnulib-tool @@ -4201,6 +4201,25 @@ func_emit_tests_Makefile_am () fi done echo + # Insert a '-Wno-error' option in the compilation commands emitted by + # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@. + # Why? + # 1) Because parts of the Gnulib tests exercise corner cases (invalid + # arguments, endless recursions, etc.) that a compiler may warn about, + # even with just the normal '-Wall' option. + # 2) Because every package maintainer has their preferred set of warnings + # that they may want to enforce in the main source code of their pack= age. + # But Gnulib tests are maintained in Gnulib and don't end up in binar= ies + # that that package installs; therefore it does not make sense for + # package maintainers to enforce the absence of warnings on these tes= ts. + # Why before @CFLAGS@? + # - Because "the user is always right": If a user adds '-Werror' to their + # CFLAGS, they have asked for errors, they will get errors. But they h= ave + # no right to complain about these errors, because Gnulib does not sup= port + # '-Werror'. + echo "CFLAGS =3D @GL_CFLAG_ALLOW_WARNINGS@ @CFLAGS@" + echo "CXXFLAGS =3D @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@" + echo echo "AM_CPPFLAGS =3D \\" if $for_test; then echo " -DGNULIB_STRICT_CHECKING=3D1 \\" @@ -4248,6 +4267,14 @@ func_emit_tests_Makefile_am () echo cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \ | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g' + # Arrange to print a message before compiling the files in this director= y. + echo "all: all-notice" + echo "all-notice:" + echo " @echo '## ---------------------------------------------------- ##= '" + echo " @echo '## ------------------- Gnulib tests ------------------- ##= '" + echo " @echo '## You can ignore compiler warnings in this directory. ##= '" + echo " @echo '## ---------------------------------------------------- ##= '" + echo echo "# Clean up after Solaris cc." echo "clean-local:" echo " rm -rf SunWS_cache" @@ -4262,9 +4289,11 @@ func_emit_tests_Makefile_am () rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets } =20 =2D# func_emit_initmacro_start macro_prefix +# func_emit_initmacro_start macro_prefix gentests # emits the first few statements of the gl_INIT macro to standard output. # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use +# - gentests true if a tests Makefile.am is being generate= d, +# false otherwise # - module_indicator_prefix prefix of GNULIB_ variables to use func_emit_initmacro_start () { @@ -4298,6 +4327,10 @@ func_emit_initmacro_start () # Scope the GNULIB_ variables. echo " m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [${module_indicator_pre= fix}])" echo " gl_COMMON" + if "$2"; then + echo " AC_REQUIRE([gl_CC_ALLOW_WARNINGS])" + echo " AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])" + fi } =20 # func_emit_initmacro_end macro_prefix @@ -5778,7 +5811,7 @@ s,//*$,/,' sed_replace_build_aux=3D"$sed_noop" fi echo " gl_m4_base=3D'$m4base'" =2D func_emit_initmacro_start $macro_prefix + func_emit_initmacro_start $macro_prefix false echo " gl_source_base=3D'$sourcebase'" if test -n "$witness_c_macro"; then echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macr= o])" @@ -5791,7 +5824,7 @@ s,//*$,/,' func_emit_initmacro_end $macro_prefix echo " gltests_libdeps=3D" echo " gltests_ltlibdeps=3D" =2D func_emit_initmacro_start ${macro_prefix}tests + func_emit_initmacro_start ${macro_prefix}tests $gentests echo " gl_source_base=3D'$testsbase'" # Define a tests witness macro that depends on the package. # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined b= y AC_INIT. @@ -6436,7 +6469,7 @@ func_create_testdir () ba }' echo "gl_m4_base=3D'../$m4base'" =2D func_emit_initmacro_start $macro_prefix + func_emit_initmacro_start $macro_prefix true # We don't have explicit ordering constraints between the various # autoconf snippets. It's cleanest to put those of the library befo= re # those of the tests. @@ -6552,7 +6585,7 @@ func_create_testdir () sed_replace_build_aux=3D"$sed_noop" fi echo "gl_m4_base=3D'$m4base'" =2D func_emit_initmacro_start $macro_prefix + func_emit_initmacro_start $macro_prefix false echo "gl_source_base=3D'$sourcebase'" if $single_configure; then func_emit_autoconf_snippets "$main_modules" "$main_modules" func_veri= fy_module true false false @@ -6563,7 +6596,7 @@ func_create_testdir () if $single_configure; then echo " gltests_libdeps=3D" echo " gltests_ltlibdeps=3D" =2D func_emit_initmacro_start ${macro_prefix}tests + func_emit_initmacro_start ${macro_prefix}tests true echo " gl_source_base=3D'$testsbase'" # Define a tests witness macro. echo " ${macro_prefix}tests_WITNESS=3DIN_GNULIB_TESTS" diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 7db4be1..bfa1645 100644 =2D-- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ =2D# gnulib-common.m4 serial 65 +# gnulib-common.m4 serial 66 dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -666,6 +666,72 @@ AC_DEFUN([gl_CACHE_VAL_SILENT], ]) ]) =20 +# gl_CC_ALLOW_WARNINGS +# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) opti= on +# that reverts a preceding '-Werror' option, if available. +# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), x= lclang +# and empty otherwise. +AC_DEFUN([gl_CC_ALLOW_WARNINGS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([for C compiler option to allow warnings], + [gl_cv_cc_wallow], + [rm -f conftest* + echo 'int dummy;' > conftest.c + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.= err]) >/dev/null + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2= >conftest2.err]) >/dev/null + dnl Test the number of error output lines, because AIX xlc accepts the + dnl option '-Wno-error', just to produce a warning + dnl "Option -Wno-error was incorrectly specified. The option will be = ignored." + dnl afterwards. + if test $? =3D 0 && test `wc -l < conftest1.err` =3D `wc -l < conftes= t2.err`; then + gl_cv_cc_wallow=3D'-Wno-error' + else + gl_cv_cc_wallow=3Dnone + fi + rm -f conftest* + ]) + case "$gl_cv_cc_wallow" in + none) GL_CFLAG_ALLOW_WARNINGS=3D'' ;; + *) GL_CFLAG_ALLOW_WARNINGS=3D"$gl_cv_cc_wallow" ;; + esac + AC_SUBST([GL_CFLAG_ALLOW_WARNINGS]) +]) + +# gl_CXX_ALLOW_WARNINGS +# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) op= tion +# that reverts a preceding '-Werror' option, if available. +AC_DEFUN([gl_CXX_ALLOW_WARNINGS], +[ + dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX. + if test -n "$CXX" && test "$CXX" !=3D no; then + AC_CACHE_CHECK([for C++ compiler option to allow warnings], + [gl_cv_cxx_wallow], + [rm -f conftest* + echo 'int dummy;' > conftest.cc + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>con= ftest1.err]) >/dev/null + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c confte= st.cc 2>conftest2.err]) >/dev/null + dnl Test the number of error output lines, because AIX xlC accepts = the + dnl option '-Wno-error', just to produce a warning + dnl "Option -Wno-error was incorrectly specified. The option will b= e ignored." + dnl afterwards. + if test $? =3D 0 && test `wc -l < conftest1.err` =3D `wc -l < conft= est2.err`; then + gl_cv_cxx_wallow=3D'-Wno-error' + else + gl_cv_cxx_wallow=3Dnone + fi + rm -f conftest* + ]) + case "$gl_cv_cxx_wallow" in + none) GL_CXXFLAG_ALLOW_WARNINGS=3D'' ;; + *) GL_CXXFLAG_ALLOW_WARNINGS=3D"$gl_cv_cxx_wallow" ;; + esac + else + GL_CXXFLAG_ALLOW_WARNINGS=3D'' + fi + AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS]) +]) + dnl Expands to some code for use in .c programs that, on native Windows, d= efines dnl the Microsoft deprecated alias function names to the underscore-prefix= ed dnl actual function names. With this macro, these function names are avail= able