From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7872) id C2D673858D33; Tue, 24 Jan 2023 03:20:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2D673858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674530414; bh=x+iDg24TActNpPJphyaZffO2zGBjmVgsOZ0KNFgtQhc=; h=From:To:Subject:Date:From; b=TV22it+OF2SeFEonC3tKuIlDFWhkrUBhX4yFhRi3ybraFFHsN3rO/y31UZzTeqxaX iUti5P8g8FUtr+gc+xBOrRlwllt5/LvISoYbr59WMUY1Yiq6o2xIG+MKOIVxAL6tZO NUkMEJSWWezC/srVbJ//J2YtaWx9uH/3IJ2p213I= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Enze Li To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: some int to bool conversion X-Act-Checkin: binutils-gdb X-Git-Author: Enze Li X-Git-Refname: refs/heads/master X-Git-Oldrev: 7ebf464bbd5099a10189c9b3935bff64ddcf5ca8 X-Git-Newrev: 59d49a8d83a289624a1dff4e8833f2b7c286d764 Message-Id: <20230124032014.C2D673858D33@sourceware.org> Date: Tue, 24 Jan 2023 03:20:14 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D59d49a8d83a2= 89624a1dff4e8833f2b7c286d764 commit 59d49a8d83a289624a1dff4e8833f2b7c286d764 Author: Enze Li Date: Sun Jan 22 13:38:41 2023 +0800 gdb: some int to bool conversion =20 When building GDB with clang 16, I got this, =20 CXX maint.o maint.c:1045:23: error: implicit truncation from 'int' to a one-bit wid= e bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-const= ant-conversion] m_space_enabled =3D 1; ^ ~ maint.c:1057:22: error: implicit truncation from 'int' to a one-bit wid= e bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-const= ant-conversion] m_time_enabled =3D 1; ^ ~ maint.c:1073:24: error: implicit truncation from 'int' to a one-bit wid= e bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-const= ant-conversion] m_symtab_enabled =3D 1; ^ ~ 3 errors generated. =20 Work around this by using bool bitfields instead. =20 Tested by rebuilding on x86_64-linux with clang 16 and gcc 12. =20 Approved-By: Tom Tromey Diff: --- gdb/maint.c | 12 ++++++------ gdb/maint.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/maint.c b/gdb/maint.c index 1a226bf75e3..52f91a3246f 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -1042,11 +1042,11 @@ scoped_command_stats::scoped_command_stats (bool ms= g_type) #ifdef HAVE_USEFUL_SBRK char *lim =3D (char *) sbrk (0); m_start_space =3D lim - lim_at_start; - m_space_enabled =3D 1; + m_space_enabled =3D true; #endif } else - m_space_enabled =3D 0; + m_space_enabled =3D false; =20 if (msg_type =3D=3D 0 || per_command_time) { @@ -1054,13 +1054,13 @@ scoped_command_stats::scoped_command_stats (bool ms= g_type) =20 m_start_cpu_time =3D run_time_clock::now (); m_start_wall_time =3D steady_clock::now (); - m_time_enabled =3D 1; + m_time_enabled =3D true; =20 if (per_command_time) print_time (_("command started")); } else - m_time_enabled =3D 0; + m_time_enabled =3D false; =20 if (msg_type =3D=3D 0 || per_command_symtab) { @@ -1070,10 +1070,10 @@ scoped_command_stats::scoped_command_stats (bool ms= g_type) m_start_nr_symtabs =3D nr_symtabs; m_start_nr_compunit_symtabs =3D nr_compunit_symtabs; m_start_nr_blocks =3D nr_blocks; - m_symtab_enabled =3D 1; + m_symtab_enabled =3D true; } else - m_symtab_enabled =3D 0; + m_symtab_enabled =3D false; =20 /* Initialize timer to keep track of how long we waited for the user. */ reset_prompt_for_continue_wait_time (); diff --git a/gdb/maint.h b/gdb/maint.h index 09a68c17bef..1741d132567 100644 --- a/gdb/maint.h +++ b/gdb/maint.h @@ -49,9 +49,9 @@ class scoped_command_stats /* Track whether the stat was enabled at the start of the command so that we can avoid printing anything if it gets turned on by the current command. */ - int m_time_enabled : 1; - int m_space_enabled : 1; - int m_symtab_enabled : 1; + bool m_time_enabled : 1; + bool m_space_enabled : 1; + bool m_symtab_enabled : 1; run_time_clock::time_point m_start_cpu_time; std::chrono::steady_clock::time_point m_start_wall_time; long m_start_space;