summaryrefslogtreecommitdiff
path: root/gdb/target-float.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-05 13:46:47 -0600
committerTom Tromey <tom@tromey.com>2018-09-05 21:47:33 -0600
commitf1628857d783fee0171f16f1bad0b7816460dec5 (patch)
tree1d26179d33bed1c082d11d0d6c3d33160792d7d9 /gdb/target-float.c
parentaf39b1c216ffb11e6ca8e8607b00749e0fc1ab41 (diff)
downloadbinutils-gdb-f1628857d783fee0171f16f1bad0b7816460dec5.tar.gz
Make -Wformat-nonliteral work with gcc
After looking into why the build failed for Simon but not for me, we found that the underlying cause was due to how gcc treats -Wformat-nonliteral. gcc requires -Wformat to be given first; but warning.m4 was not doing this, so -Wformat-nonliteral was not being used. This patch changes warning.m4 to account gcc's requirement. This then showed that the target-float.c build change in the earlier Makefile patch was also incorrect. Simon didn't see this in his build, but gcc now points it out. So, this patch fixes this problem as well. 2018-09-05 Tom Tromey <tom@tromey.com> * warning.m4 (AM_GDB_WARNINGS): Add -Wformat when testing -Wformat-nonliteral. * target-float.c (host_float_ops<T>::to_string) (host_float_ops<T>::from_string): Use DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL. * configure: Rebuild. gdb/gdbserver/ChangeLog 2018-09-05 Tom Tromey <tom@tromey.com> * configure: Rebuild.
Diffstat (limited to 'gdb/target-float.c')
-rw-r--r--gdb/target-float.c7
1 files changed, 7 insertions, 0 deletions
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<T>::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<T>::from_string (gdb_byte *addr, const struct type *type,
scan_format += scanf_length_modifier<T>::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.