diff mbox series

[v2,3/5] configure: Clean up warning flag lists

Message ID 20200610203942.887374-4-richard.henderson@linaro.org
State Superseded
Headers show
Series Vs clang-10 and gcc-9 warnings | expand

Commit Message

Richard Henderson June 10, 2020, 8:39 p.m. UTC
Use a helper function to tidy the assembly of gcc_flags.
Separate flags that disable warnings from those that enable,
and sort the disable warnings to the end.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 configure | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

-- 
2.25.1

Comments

Eric Blake June 11, 2020, 2:25 p.m. UTC | #1
On 6/10/20 3:39 PM, Richard Henderson wrote:
> Use a helper function to tidy the assembly of gcc_flags.

> Separate flags that disable warnings from those that enable,

> and sort the disable warnings to the end.

> 

> Suggested-by: Eric Blake <eblake@redhat.com>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>   configure | 40 ++++++++++++++++++++++++++++++----------

>   1 file changed, 30 insertions(+), 10 deletions(-)

> 


> +# Accumulate -Wfoo and -Wno-bar separately.

> +# We will list all of the enable flags first, and the disable flags second.

> +# Note that we do not add -Werror, because that would enable it for all

> +# configure tests. If a configure test failed due to -Werror this would

> +# just silently disable some features, so it's too error prone.

> +

> +add_to warn_flags -Wold-style-declaration


Hmm - should we add:
warn_flags= nowarn_flags=
prior to this line, to ensure that something inherited from the 
environment doesn't mess us up.

> +add_to warn_flags -Wold-style-definition

> +add_to warn_flags -Wtype-limits

> +add_to warn_flags -Wformat-security

> +add_to warn_flags -Wformat-y2k

> +add_to warn_flags -Winit-self

> +add_to warn_flags -Wignored-qualifiers

> +add_to warn_flags -Wempty-body

> +add_to warn_flags -Wnested-externs

> +add_to warn_flags -Wendif-labels

> +add_to warn_flags -Wno-initializer-overrides


wrong list

> +add_to warn_flags -Wexpansion-to-defined

> +

> +add_to nowarn_flags -Wno-missing-include-dirs

> +add_to nowarn_flags -Wno-shift-negative-value

> +add_to nowarn_flags -Wno-string-plus-int

> +add_to nowarn_flags -Wno-typedef-redefinition

> +

> +gcc_flags="$warn_flags $nowarn_flags"


Otherwise looks sane.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Richard Henderson June 17, 2020, 1:29 a.m. UTC | #2
On 6/11/20 7:25 AM, Eric Blake wrote:
>> +add_to warn_flags -Wold-style-declaration

> 

> Hmm - should we add:

> warn_flags= nowarn_flags=

> prior to this line, to ensure that something inherited from the environment

> doesn't mess us up.

> 

>> +add_to warn_flags -Wold-style-definition

>> +add_to warn_flags -Wtype-limits

>> +add_to warn_flags -Wformat-security

>> +add_to warn_flags -Wformat-y2k

>> +add_to warn_flags -Winit-self

>> +add_to warn_flags -Wignored-qualifiers

>> +add_to warn_flags -Wempty-body

>> +add_to warn_flags -Wnested-externs

>> +add_to warn_flags -Wendif-labels

>> +add_to warn_flags -Wno-initializer-overrides

> 

> wrong list


Thanks, fixed both.


r~
diff mbox series

Patch

diff --git a/configure b/configure
index 597e909b53..464202e375 100755
--- a/configure
+++ b/configure
@@ -97,6 +97,11 @@  do_cxx() {
     do_compiler "$cxx" "$@"
 }
 
+# Append $2 to the variable named $1, with space separation
+add_to() {
+    eval $1=\${$1:+\"\$$1 \"}\$2
+}
+
 update_cxxflags() {
     # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
     # options which some versions of GCC's C++ compiler complain about
@@ -2007,16 +2012,31 @@  if ! compile_prog "" "" ; then
     error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
 fi
 
-gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
-gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
-gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
-gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
-gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
-gcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags"
-# Note that we do not add -Werror to gcc_flags here, because that would
-# enable it for all configure tests. If a configure test failed due
-# to -Werror this would just silently disable some features,
-# so it's too error prone.
+# Accumulate -Wfoo and -Wno-bar separately.
+# We will list all of the enable flags first, and the disable flags second.
+# Note that we do not add -Werror, because that would enable it for all
+# configure tests. If a configure test failed due to -Werror this would
+# just silently disable some features, so it's too error prone.
+
+add_to warn_flags -Wold-style-declaration
+add_to warn_flags -Wold-style-definition
+add_to warn_flags -Wtype-limits
+add_to warn_flags -Wformat-security
+add_to warn_flags -Wformat-y2k
+add_to warn_flags -Winit-self
+add_to warn_flags -Wignored-qualifiers
+add_to warn_flags -Wempty-body
+add_to warn_flags -Wnested-externs
+add_to warn_flags -Wendif-labels
+add_to warn_flags -Wno-initializer-overrides
+add_to warn_flags -Wexpansion-to-defined
+
+add_to nowarn_flags -Wno-missing-include-dirs
+add_to nowarn_flags -Wno-shift-negative-value
+add_to nowarn_flags -Wno-string-plus-int
+add_to nowarn_flags -Wno-typedef-redefinition
+
+gcc_flags="$warn_flags $nowarn_flags"
 
 cc_has_warning_flag() {
     write_c_skeleton;