Skip to content

Commit 00849b9

Browse files
rth7680pm215
authored andcommitted
configure: Clean up warning flag lists
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. Reviewed-by: Alex Bennée <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-id: [email protected] Suggested-by: Eric Blake <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Signed-off-by: Peter Maydell <[email protected]>
1 parent 9227140 commit 00849b9

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

configure

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ do_cxx() {
9797
do_compiler "$cxx" "$@"
9898
}
9999

100+
# Append $2 to the variable named $1, with space separation
101+
add_to() {
102+
eval $1=\${$1:+\"\$$1 \"}\$2
103+
}
104+
100105
update_cxxflags() {
101106
# Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
102107
# options which some versions of GCC's C++ compiler complain about
@@ -2024,16 +2029,33 @@ if ! compile_prog "" "" ; then
20242029
error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
20252030
fi
20262031

2027-
gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
2028-
gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
2029-
gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
2030-
gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
2031-
gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
2032-
gcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags"
2033-
# Note that we do not add -Werror to gcc_flags here, because that would
2034-
# enable it for all configure tests. If a configure test failed due
2035-
# to -Werror this would just silently disable some features,
2036-
# so it's too error prone.
2032+
# Accumulate -Wfoo and -Wno-bar separately.
2033+
# We will list all of the enable flags first, and the disable flags second.
2034+
# Note that we do not add -Werror, because that would enable it for all
2035+
# configure tests. If a configure test failed due to -Werror this would
2036+
# just silently disable some features, so it's too error prone.
2037+
2038+
warn_flags=
2039+
add_to warn_flags -Wold-style-declaration
2040+
add_to warn_flags -Wold-style-definition
2041+
add_to warn_flags -Wtype-limits
2042+
add_to warn_flags -Wformat-security
2043+
add_to warn_flags -Wformat-y2k
2044+
add_to warn_flags -Winit-self
2045+
add_to warn_flags -Wignored-qualifiers
2046+
add_to warn_flags -Wempty-body
2047+
add_to warn_flags -Wnested-externs
2048+
add_to warn_flags -Wendif-labels
2049+
add_to warn_flags -Wexpansion-to-defined
2050+
2051+
nowarn_flags=
2052+
add_to nowarn_flags -Wno-initializer-overrides
2053+
add_to nowarn_flags -Wno-missing-include-dirs
2054+
add_to nowarn_flags -Wno-shift-negative-value
2055+
add_to nowarn_flags -Wno-string-plus-int
2056+
add_to nowarn_flags -Wno-typedef-redefinition
2057+
2058+
gcc_flags="$warn_flags $nowarn_flags"
20372059

20382060
cc_has_warning_flag() {
20392061
write_c_skeleton;

0 commit comments

Comments
 (0)