From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CcqeDE0wNGpc3g0AWB0awg (envelope-from ) for ; Thu, 18 Jun 2026 13:52:13 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=UCbSn/Bw; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 306A31E070; Thu, 18 Jun 2026 13:52:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 62C191E070 for ; Thu, 18 Jun 2026 13:52:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8E0924BA79A0 for ; Thu, 18 Jun 2026 17:52:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E0924BA79A0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=UCbSn/Bw Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id E00214BA2E22 for ; Thu, 18 Jun 2026 17:51:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E00214BA2E22 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E00214BA2E22 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781805086; cv=none; b=mDVW28o76tbK8tpaUKR1/H/CaBfXi3KI4ABpnhcHMFOg37GnUvF1eeXB8LVXabWz3W0U/AqVlmrIsWrYvn8iMaeqbdO1uDS1IayyEvCNHxpJ4lMRHH47P23i5tTs16eeXuFZE0IjNLX2fN1NiY7+cyNd47KA9DRGYtx5F5kYjjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781805086; c=relaxed/simple; bh=Oj5btXE7Tw8CselH/PXOllowkrNOFabibhyJRfOPAr0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gHZDMJbi1JF1a829ZtvXtbjl9KlhF+sbM6P3jUKSdlaIuFPElIwJZP4SW+Vytjz4NTKpH/LZJSvy84XWI2KSTX2S5j9y0axDYiVrpnYlGTBfsyMRhPyTf8FGVUKdtSb4jXrGTvoNIwCCM3DpsTS26RnohXwik9f2lWf/b9kj9mM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=UCbSn/Bw DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E00214BA2E22 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 65IHpJ09121390 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 13:51:23 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 65IHpJ09121390 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1781805084; bh=0wgx7GxDF9OsKre9n3AWebPtB3U/ozMXN7Tti83Bh9Q=; h=From:To:Cc:Subject:Date:From; b=UCbSn/BwrILQFWAhXrnz+cEt3iJTqZa03hmlESKsu9p5E1eEZq2lEmAs2A8wgRcAq 9LHISipCZ5FG4rZqJ6uGxKqOWIX+aIrJ0DesunS9SXSbfMF5cXSx3nV1/STFeoeeRL 2nPwTN3AMEGeFhdm3rZ1JQBoqkWwuPniMGc7a/Kn3HFXSCT+62G9nF3glb+icxSME4 OjakInM19oqQnk1M7ueE9PjaGLlEfWcjG6XLbU7B8bs8N0QS+Oz1lKFfzgfBIPouJy EE/APvUzyIW/dI2zQOSb7wMFbPNwVvFsaVfBjnPcuHZ5+8zA8JV/ZM0WnipRnvAFqk GBewvnNJO/NrA== Received: by simark.ca (Postfix) id 2668E1E070; Thu, 18 Jun 2026 13:51:19 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb, gdbserver, gdbsupport: use [[maybe_unused]] instead of ATTRIBUTE_UNUSED Date: Thu, 18 Jun 2026 13:50:59 -0400 Message-ID: <20260618175118.3758778-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 18 Jun 2026 17:51:19 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Simon Marchi Since we require C++17, replace the uses of the ATTRIBUTE_UNUSED macro (which expands to __attribute__ ((__unused__))) with the standard [[maybe_unused]] attribute. I think that some of these attribute uses are not necessary, but I did not make an attempt to remove them, that would be for another patch. Change-Id: I62529d94153c65e2b3c49ff5330292e60c8a0f9e --- gdb/inferior.c | 4 ++-- gdb/inflow.c | 2 +- gdb/linux-fork.c | 2 +- gdb/mi/mi-interp.c | 2 +- gdb/python/py-utils.c | 2 +- gdb/remote.c | 2 +- gdb/source-cache.c | 6 +++--- gdb/thread.c | 4 ++-- gdb/typeprint.c | 4 ++-- gdb/unittests/enum-flags-selftests.c | 4 ++-- gdb/valprint.c | 4 ++-- gdbserver/linux-aarch64-low.cc | 6 +++--- gdbserver/x86-tdesc.h | 4 ++-- gdbsupport/safe-strerror.cc | 4 ++-- gdbsupport/thread-pool.cc | 6 +++--- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/gdb/inferior.c b/gdb/inferior.c index 1481f46cdd18..7d54845f28ac 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -432,7 +432,7 @@ find_inferior_for_program_space (struct program_space *pspace) int have_inferiors (void) { - for (inferior *inf ATTRIBUTE_UNUSED : all_non_exited_inferiors ()) + for ([[maybe_unused]] inferior *inf : all_non_exited_inferiors ()) return 1; return 0; @@ -449,7 +449,7 @@ number_of_live_inferiors (process_stratum_target *proc_target) for (inferior *inf : all_non_exited_inferiors (proc_target)) if (inf->has_execution ()) - for (thread_info &tp ATTRIBUTE_UNUSED : inf->non_exited_threads ()) + for ([[maybe_unused]] thread_info &tp : inf->non_exited_threads ()) { /* Found a live thread in this inferior, go to the next inferior. */ diff --git a/gdb/inflow.c b/gdb/inflow.c index c40ad2cf5294..e3a080dbd657 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -493,7 +493,7 @@ child_terminal_ours_1 (target_terminal_state desired_state) if (gdb_tty_state != desired_state) { - int result ATTRIBUTE_UNUSED; + [[maybe_unused]] int result; /* Ignore SIGTTOU since it will happen when we try to set the terminal's pgrp. */ diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 92afa4dde6db..fac35e13afb8 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -963,7 +963,7 @@ inf_has_multiple_threads () /* Return true as soon as we see the second thread of the current inferior. */ - for (thread_info &tp ATTRIBUTE_UNUSED : current_inferior ()->threads ()) + for ([[maybe_unused]] thread_info &tp : current_inferior ()->threads ()) if (++count > 1) return true; diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 1a0d34106ed1..998409563e97 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -637,7 +637,7 @@ static bool multiple_inferiors_p () { int count = 0; - for (inferior *inf ATTRIBUTE_UNUSED : all_non_exited_inferiors ()) + for ([[maybe_unused]] inferior *inf : all_non_exited_inferiors ()) { count++; if (count > 1) diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index a831b96eb387..3979343acde9 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -314,7 +314,7 @@ gdb_py_int_as_long (PyObject *obj, long *result) PyObject * gdb_py_generic_dict_getter (PyObject *self, - void *closure ATTRIBUTE_UNUSED) + [[maybe_unused]] void *closure) { PyObject **py_dict_ptr = gdbpy_dict_wrapper::compute_addr (self); PyObject *py_dict = *py_dict_ptr; diff --git a/gdb/remote.c b/gdb/remote.c index f8c7383cb037..43df087b83b3 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4546,7 +4546,7 @@ static bool has_single_non_exited_thread (inferior *inf) { int count = 0; - for (thread_info &tp ATTRIBUTE_UNUSED : inf->non_exited_threads ()) + for ([[maybe_unused]] thread_info &tp : inf->non_exited_threads ()) if (++count > 1) break; return count == 1; diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 6e8acab35044..0a64745ee585 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -199,9 +199,9 @@ get_language_name (enum language lang) succeeded. */ static bool -try_source_highlight (std::string &contents ATTRIBUTE_UNUSED, - enum language lang ATTRIBUTE_UNUSED, - const std::string &fullname ATTRIBUTE_UNUSED) +try_source_highlight ([[maybe_unused]] std::string &contents, + [[maybe_unused]] enum language lang, + [[maybe_unused]] const std::string &fullname) { #ifdef HAVE_SOURCE_HIGHLIGHT if (!use_gnu_source_highlight) diff --git a/gdb/thread.c b/gdb/thread.c index 96c733e0629b..ffb980546b93 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -476,7 +476,7 @@ thread_step_over_chain_length (const thread_step_over_list &l) { int num = 0; - for (const thread_info &thread ATTRIBUTE_UNUSED : l) + for ([[maybe_unused]] const thread_info &thread : l) ++num; return num; @@ -626,7 +626,7 @@ find_thread (find_thread_callback_ftype callback) bool any_thread_p () { - for (thread_info &tp ATTRIBUTE_UNUSED : all_threads ()) + for ([[maybe_unused]] thread_info &tp : all_threads ()) return true; return false; } diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 31a9c1814a31..01c6c218a5d5 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -516,11 +516,11 @@ ptype_command (const char *type_name, int from_tty) } /* Meant to be used in debug sessions, so don't export it in a header file. */ -extern void ATTRIBUTE_UNUSED debug_type (struct type *type); +[[maybe_unused]] extern void debug_type (struct type *type); /* Print TYPE. */ -void ATTRIBUTE_UNUSED +[[maybe_unused]] void debug_type (struct type *type) { type_print (type, "", gdb_stdlog, 1); diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c index bf748e873035..ca404bfa3ebe 100644 --- a/gdb/unittests/enum-flags-selftests.c +++ b/gdb/unittests/enum-flags-selftests.c @@ -70,8 +70,8 @@ static_assert (std::is_trivially_copyable::value); below. Their names (and types) match the uppercase type names exposed by CHECK_VALID just to make the expressions easier to follow. */ -static RawEnum re ATTRIBUTE_UNUSED; -static EnumFlag ef ATTRIBUTE_UNUSED; +[[maybe_unused]] static RawEnum re; +[[maybe_unused]] static EnumFlag ef; /* First, compile-time tests that: diff --git a/gdb/valprint.c b/gdb/valprint.c index 50a4663ca3b5..67bfbf589301 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1232,11 +1232,11 @@ value_print (struct value *val, struct ui_file *stream, } /* Meant to be used in debug sessions, so don't export it in a header file. */ -extern void ATTRIBUTE_UNUSED debug_val (struct value *val); +[[maybe_unused]] extern void debug_val (struct value *val); /* Print VAL. */ -void ATTRIBUTE_UNUSED +[[maybe_unused]] void debug_val (struct value *val) { value_print (val, gdb_stdlog, &user_print_options); diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index a2588a6e2a9c..b68d39e1b803 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -741,7 +741,7 @@ aarch64_target::low_new_fork (process_info *parent, static void aarch64_sve_regs_copy_to_regcache (struct regcache *regcache, - ATTRIBUTE_UNUSED const void *buf) + [[maybe_unused]] const void *buf) { /* BUF is unused here since we collect the data straight from a ptrace request in aarch64_sve_regs_copy_to_reg_buf, therefore bypassing @@ -776,7 +776,7 @@ aarch64_sve_regs_copy_from_regcache (struct regcache *regcache, void *buf) static void aarch64_za_regs_copy_to_regcache (struct regcache *regcache, - ATTRIBUTE_UNUSED const void *buf) + [[maybe_unused]] const void *buf) { /* BUF is unused here since we collect the data straight from a ptrace request, therefore bypassing gdbserver's own call to ptrace. */ @@ -822,7 +822,7 @@ aarch64_za_regs_copy_from_regcache (struct regcache *regcache, void *buf) static void aarch64_zt_regs_copy_to_regcache (struct regcache *regcache, - ATTRIBUTE_UNUSED const void *buf) + [[maybe_unused]] const void *buf) { /* BUF is unused here since we collect the data straight from a ptrace request, therefore bypassing gdbserver's own call to ptrace. */ diff --git a/gdbserver/x86-tdesc.h b/gdbserver/x86-tdesc.h index 4ed6d6635bbb..ce0c6c1be90d 100644 --- a/gdbserver/x86-tdesc.h +++ b/gdbserver/x86-tdesc.h @@ -20,8 +20,8 @@ /* The "expedite" registers for x86 targets. Since whether the variable is used depends on host/configuration, we mark it - ATTRIBUTE_UNUSED to keep it simple here. */ -static const char *i386_expedite_regs[] ATTRIBUTE_UNUSED + [[maybe_unused]] to keep it simple here. */ +[[maybe_unused]] static const char *i386_expedite_regs[] = {"ebp", "esp", "eip", NULL}; #ifdef __x86_64__ diff --git a/gdbsupport/safe-strerror.cc b/gdbsupport/safe-strerror.cc index d53cf84511fd..ad25cfc3d765 100644 --- a/gdbsupport/safe-strerror.cc +++ b/gdbsupport/safe-strerror.cc @@ -26,14 +26,14 @@ function. */ /* Called if we have a XSI-compliant strerror_r. */ -ATTRIBUTE_UNUSED static char * +[[maybe_unused]] static char * select_strerror_r (int res, char *buf) { return res == 0 ? buf : nullptr; } /* Called if we have a GNU strerror_r. */ -ATTRIBUTE_UNUSED static char * +[[maybe_unused]] static char * select_strerror_r (char *res, char *) { return res; diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc index 4dc72e566428..12329ea98831 100644 --- a/gdbsupport/thread-pool.cc +++ b/gdbsupport/thread-pool.cc @@ -44,14 +44,14 @@ takes a printf-style format and an argument. This wrapper handles the difference. */ -ATTRIBUTE_UNUSED static void +[[maybe_unused]] static void do_set_thread_name (int (*set_name) (pthread_t, const char *, void *), const char *name) { set_name (pthread_self (), "%s", const_cast (name)); } -ATTRIBUTE_UNUSED static void +[[maybe_unused]] static void do_set_thread_name (int (*set_name) (pthread_t, const char *), const char *name) { @@ -60,7 +60,7 @@ do_set_thread_name (int (*set_name) (pthread_t, const char *), /* The macOS man page says that pthread_setname_np returns "void", but the headers actually declare it returning "int". */ -ATTRIBUTE_UNUSED static void +[[maybe_unused]] static void do_set_thread_name (int (*set_name) (const char *), const char *name) { set_name (name); base-commit: cdfda31c0d6b85cfff7fddeabffa570176161548 -- 2.54.0