diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d8ca6d3dabd..69e3182ec32 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2018-09-05 Tom Tromey + + * warning.m4 (AM_GDB_WARNINGS): Add -Wformat when testing + -Wformat-nonliteral. + * target-float.c (host_float_ops::to_string) + (host_float_ops::from_string): Use + DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL. + * configure: Rebuild. + 2018-09-05 Simon Marchi * printcmd.c (printf_c_string): Use diff --git a/gdb/configure b/gdb/configure index 270657103b6..d92a256f1ff 100755 --- a/gdb/configure +++ b/gdb/configure @@ -15427,7 +15427,10 @@ case "${host}" in build_warnings="$build_warnings -Wno-unknown-pragmas" # Solaris 11 marks vfork deprecated. build_warnings="$build_warnings -Wno-deprecated-declarations" ;; - *) build_warnings="$build_warnings -Wformat-nonliteral" ;; + *) + # Note that gcc requires -Wformat for -Wformat-nonliteral to work, + # but there's a special case for this below. + build_warnings="$build_warnings -Wformat-nonliteral" ;; esac # Check whether --enable-build-warnings was given. @@ -15483,6 +15486,12 @@ $as_echo_n "checking compiler warning flags... " >&6; } case $w in -Wno-*) wtest=`echo $w | sed 's/-Wno-/-W/g'` ;; + -Wformat-nonliteral) + # gcc requires -Wformat before -Wformat-nonliteral + # will work, so stick them together. + w="-Wformat $w" + wtest="$w" + ;; *) wtest=$w ;; esac diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index cd0318c79aa..0c5c32b22ef 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,7 @@ +2018-09-05 Tom Tromey + + * configure: Rebuild. + 2018-08-28 Simon Marchi PR build/23399 diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index 7454cd8ad37..f5cbbaea78a 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -7258,7 +7258,10 @@ case "${host}" in build_warnings="$build_warnings -Wno-unknown-pragmas" # Solaris 11 marks vfork deprecated. build_warnings="$build_warnings -Wno-deprecated-declarations" ;; - *) build_warnings="$build_warnings -Wformat-nonliteral" ;; + *) + # Note that gcc requires -Wformat for -Wformat-nonliteral to work, + # but there's a special case for this below. + build_warnings="$build_warnings -Wformat-nonliteral" ;; esac # Check whether --enable-build-warnings was given. @@ -7314,6 +7317,12 @@ $as_echo_n "checking compiler warning flags... " >&6; } case $w in -Wno-*) wtest=`echo $w | sed 's/-Wno-/-W/g'` ;; + -Wformat-nonliteral) + # gcc requires -Wformat before -Wformat-nonliteral + # will work, so stick them together. + w="-Wformat $w" + wtest="$w" + ;; *) wtest=$w ;; esac diff --git a/gdb/target-float.c b/gdb/target-float.c index c2878cb0a08..a12f216b53d 100644 --- a/gdb/target-float.c +++ b/gdb/target-float.c @@ -948,7 +948,11 @@ host_float_ops::to_string (const gdb_byte *addr, const struct type *type, T host_float; from_target (type, addr, &host_float); + + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL return string_printf (host_format.c_str (), host_float); + DIAGNOSTIC_POP } /* Parse string IN into a target floating-number of type TYPE and @@ -977,7 +981,10 @@ host_float_ops::from_string (gdb_byte *addr, const struct type *type, scan_format += scanf_length_modifier::value; scan_format += "g%n"; + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL num = sscanf (in.c_str (), scan_format.c_str(), &host_float, &n); + DIAGNOSTIC_POP /* The sscanf man page suggests not making any assumptions on the effect of %n on the result, so we don't. diff --git a/gdb/warning.m4 b/gdb/warning.m4 index dd338493f9e..82170acc802 100644 --- a/gdb/warning.m4 +++ b/gdb/warning.m4 @@ -58,7 +58,10 @@ case "${host}" in build_warnings="$build_warnings -Wno-unknown-pragmas" # Solaris 11 marks vfork deprecated. build_warnings="$build_warnings -Wno-deprecated-declarations" ;; - *) build_warnings="$build_warnings -Wformat-nonliteral" ;; + *) + # Note that gcc requires -Wformat for -Wformat-nonliteral to work, + # but there's a special case for this below. + build_warnings="$build_warnings -Wformat-nonliteral" ;; esac AC_ARG_ENABLE(build-warnings, @@ -106,6 +109,12 @@ then case $w in -Wno-*) wtest=`echo $w | sed 's/-Wno-/-W/g'` ;; + -Wformat-nonliteral) + # gcc requires -Wformat before -Wformat-nonliteral + # will work, so stick them together. + w="-Wformat $w" + wtest="$w" + ;; *) wtest=$w ;; esac