From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10349 invoked by alias); 6 Sep 2018 03:39:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 10275 invoked by uid 89); 6 Sep 2018 03:39:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Rebuild X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Sep 2018 03:39:23 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 625E11E029 for ; Wed, 5 Sep 2018 22:39:22 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id xl8Gff3vzbXuJxl8Ufz6xX; Wed, 05 Sep 2018 22:39:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=saLHcWqsa2E5E2eSOYFNBRDVrEiiKdxUUVSzV1OKbbw=; b=ijFP4d09M8xIuXXTynXSOIIDEz xDI1+Mgooe/7g37zjk5zJ35CNVjZmGTmu9in9wu0AvbiA78YVfbJxzG2dHX9NkhhRMo0Vq+E9PNJc yy8EZxseE8h60nrKYZTtNqYx6; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:43798 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fxl8G-001PJT-0L; Wed, 05 Sep 2018 22:39:00 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI 2/2] Make -Wformat-nonliteral work with gcc Date: Thu, 06 Sep 2018 03:39:00 -0000 Message-Id: <20180906033855.13635-3-tom@tromey.com> In-Reply-To: <20180906033855.13635-1-tom@tromey.com> References: <20180906033855.13635-1-tom@tromey.com> X-SW-Source: 2018-09/txt/msg00083.txt.bz2 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. gdb/ChangeLog 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. gdb/gdbserver/ChangeLog 2018-09-05 Tom Tromey * configure: Rebuild. --- gdb/ChangeLog | 9 +++++++++ gdb/configure | 11 ++++++++++- gdb/gdbserver/ChangeLog | 4 ++++ gdb/gdbserver/configure | 11 ++++++++++- gdb/target-float.c | 7 +++++++ gdb/warning.m4 | 11 ++++++++++- 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d8ca6d3dab..69e3182ec3 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 270657103b..d92a256f1f 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 cd0318c79a..0c5c32b22e 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 7454cd8ad3..f5cbbaea78 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 c2878cb0a0..a12f216b53 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 dd338493f9..82170acc80 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 -- 2.17.1