From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id waoYJ0YwNGpc3g0AWB0awg (envelope-from ) for ; Thu, 18 Jun 2026 13:52:06 -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=C0sbGjFc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9BE5E1E098; Thu, 18 Jun 2026 13:52:06 -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 1F3191E070 for ; Thu, 18 Jun 2026 13:52:06 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF37E4BA798E for ; Thu, 18 Jun 2026 17:52:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF37E4BA798E 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=C0sbGjFc Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 2BA414BA2E29 for ; Thu, 18 Jun 2026 17:51:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2BA414BA2E29 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 2BA414BA2E29 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=cdl5ON6F9LvRAkbj/THARP3m3eu4RHGp+hfQsLasNQ3qpnMNPJN8/KMfg1TZ2z832+WJPy5JUb02glC2SiSreWtZyjjNDgtir4bhyljH/OK4Km1B+wb+ZPd2e+/COsAimKVI2Xmuft9Z+Vu7QYy+fG+2oW9KsQO8dgjepvLaAgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781805086; c=relaxed/simple; bh=DZNSeqSOhuxEtLxET6lUic0scfssjSJz2g9BXNu+0rU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Sac4u6sFhWS9nX+wWSqwDLGnEqbgggpWBIdZmT9/LDA0RUJsW7NnvfTbBob42zAlRThEb7E1MMnxDUVzlRObaZrTuLIDXBvcizoLr232A+/9NXEJ0Bng2HJPox0/mbDTj+HN9PevnqmRogfVa3C04TwfEZNsLdVYXLD67NuZ8M0= 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=C0sbGjFc DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BA414BA2E29 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 65IHpJX4121393 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 13:51:24 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 65IHpJX4121393 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1781805084; bh=q8Ll+mxcyzEcaSA5VZ/SY+uYa1n2pu+9T3lYVvWLKDc=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=C0sbGjFcLow9Bhalw5CG/kxvq2SKXRHfp/dQ+yBKKeV6ozZXTxA2/G2AReXeseQsX 6Dq4po08+qoZj9A51D2v+VjbzgIuSgjHqCGVdbaocHqwbdQLfJH1jKpjm/RHDpt/c2 96B5ve8zUoGjLMxFUMpCH39cWqHrGyM9WvLbVOlP6vsRuL0LYwB+wU1N+c4a1M81dX rr/JVspUWMTvD/XpeavM5CmgyNp4n00X300gJB75F5i88QOkxo4FOoBNCxJAEMyWcv neinMIz8RkMloby6khWO/err+mICXxMvvVmZ6BP9Ud/fiZRZCWsNNAyqzGN3jcpEje U8vWHJ+BofWug== Received: by simark.ca (Postfix) id 3C3C91E091; Thu, 18 Jun 2026 13:51:19 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] gdb, gdbsupport: use [[nodiscard]] instead of ATTRIBUTE_UNUSED_RESULT Date: Thu, 18 Jun 2026 13:51:00 -0400 Message-ID: <20260618175118.3758778-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618175118.3758778-1-simon.marchi@polymtl.ca> References: <20260618175118.3758778-1-simon.marchi@polymtl.ca> 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_RESULT macro (which expands to __attribute__ ((__warn_unused_result__))) with the standard [[nodiscard]] attribute, and drop the macro definition from gdbsupport/common-defs.h. Change-Id: I6aa0386ce709e8cce81d2a705362bdd4ceccb543 --- gdb/parser-defs.h | 2 +- gdb/remote.c | 2 +- gdb/stap-probe.c | 12 +++++------- gdbsupport/buildargv.h | 2 +- gdbsupport/common-defs.h | 1 - gdbsupport/gdb_ref_ptr.h | 2 +- gdbsupport/scoped_fd.h | 2 +- gdbsupport/scoped_mmap.h | 2 +- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index cfa9d9c111da..96355eb3ca4b 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -49,7 +49,7 @@ struct expr_builder /* Resize the allocated expression to the correct size, and return it as an expression_up -- passing ownership to the caller. */ - ATTRIBUTE_UNUSED_RESULT expression_up release () + [[nodiscard]] expression_up release () { return std::move (expout); } diff --git a/gdb/remote.c b/gdb/remote.c index 43df087b83b3..e6dc3a56e28d 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -13934,7 +13934,7 @@ class scoped_remote_fd DISABLE_COPY_AND_ASSIGN (scoped_remote_fd); /* Release ownership of the file descriptor, and return it. */ - ATTRIBUTE_UNUSED_RESULT int release () noexcept + [[nodiscard]] int release () noexcept { int fd = m_fd; m_fd = -1; diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index d28cee8168c3..62fc18f7a958 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -261,13 +261,11 @@ enum stap_operand_prec STAP_OPERAND_PREC_MUL }; -static expr::operation_up stap_parse_argument_1 (struct stap_parse_info *p, - expr::operation_up &&lhs, - enum stap_operand_prec prec) - ATTRIBUTE_UNUSED_RESULT; +[[nodiscard]] static expr::operation_up stap_parse_argument_1 + (stap_parse_info *p, expr::operation_up &&lhs, stap_operand_prec prec); -static expr::operation_up stap_parse_argument_conditionally - (struct stap_parse_info *p) ATTRIBUTE_UNUSED_RESULT; +[[nodiscard]] static expr::operation_up stap_parse_argument_conditionally + (stap_parse_info *p); /* Returns true if *S is an operator, false otherwise. */ @@ -1072,7 +1070,7 @@ stap_parse_argument_conditionally (struct stap_parse_info *p) /* Helper function for `stap_parse_argument'. Please, see its comments to better understand what this function does. */ -static expr::operation_up ATTRIBUTE_UNUSED_RESULT +[[nodiscard]] static expr::operation_up stap_parse_argument_1 (struct stap_parse_info *p, expr::operation_up &&lhs_in, enum stap_operand_prec prec) diff --git a/gdbsupport/buildargv.h b/gdbsupport/buildargv.h index 788c1e38730b..6475ee174de5 100644 --- a/gdbsupport/buildargv.h +++ b/gdbsupport/buildargv.h @@ -102,7 +102,7 @@ class gdb_argv /* Return the underlying array, transferring ownership to the caller. */ - ATTRIBUTE_UNUSED_RESULT char **release () + [[nodiscard]] char **release () { char **result = m_argv; m_argv = NULL; diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h index 1c0ae0ad9d1b..ca08939676d9 100644 --- a/gdbsupport/common-defs.h +++ b/gdbsupport/common-defs.h @@ -202,7 +202,6 @@ #undef ATTRIBUTE_NONNULL #define ATTRIBUTE_NONNULL(m) -#define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) #define ATTRIBUTE_USED __attribute__ ((__used__)) #include "libiberty.h" diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h index 757c3f395bab..77aebd82e5d7 100644 --- a/gdbsupport/gdb_ref_ptr.h +++ b/gdbsupport/gdb_ref_ptr.h @@ -183,7 +183,7 @@ class ref_ptr /* Return this instance's referent, and stop managing this reference. The caller is now responsible for the ownership of the reference. */ - ATTRIBUTE_UNUSED_RESULT T *release () noexcept + [[nodiscard]] T *release () noexcept { T *result = m_obj; diff --git a/gdbsupport/scoped_fd.h b/gdbsupport/scoped_fd.h index 08102eda8ce3..03255ea8db7a 100644 --- a/gdbsupport/scoped_fd.h +++ b/gdbsupport/scoped_fd.h @@ -56,7 +56,7 @@ class scoped_fd DISABLE_COPY_AND_ASSIGN (scoped_fd); - ATTRIBUTE_UNUSED_RESULT int release () noexcept + [[nodiscard]] int release () noexcept { int fd = m_fd; m_fd = -1; diff --git a/gdbsupport/scoped_mmap.h b/gdbsupport/scoped_mmap.h index 84ad2c38a152..902a1631b2f8 100644 --- a/gdbsupport/scoped_mmap.h +++ b/gdbsupport/scoped_mmap.h @@ -52,7 +52,7 @@ class scoped_mmap DISABLE_COPY_AND_ASSIGN (scoped_mmap); - ATTRIBUTE_UNUSED_RESULT void *release () noexcept + [[nodiscard]] void *release () noexcept { void *mem = m_mem; m_mem = MAP_FAILED; -- 2.54.0