From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id C74B7386EC7E for ; Thu, 12 Nov 2020 16:03:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C74B7386EC7E Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-7edwzWoPM56S3fkWkkbx1A-1; Thu, 12 Nov 2020 11:03:23 -0500 X-MC-Unique: 7edwzWoPM56S3fkWkkbx1A-1 Received: by mail-qk1-f199.google.com with SMTP id t70so4560558qka.11 for ; Thu, 12 Nov 2020 08:03:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PxKWvhhc1o/MTus7ahtStKDAreFy181j/tFzTEKXd4s=; b=nnIsiBsTm2xAZv/P3u5cAxPehym0m9ziC1u069vZ8QiMOSg/SBKEGXjOJ5By+gizP7 UCfLDfBY6VGGys3dnBC/Y7BilWVKymdY3xMe1ugq2qgRO5+tcBXLhtDnlQHZyno4LBvm cfoiG0s59Xa03oqWmPVsxhcyha2ou+SHekTZuXMmctMwJZNkpYkU8/y3dsTsVyYKVw4w ljIG+p8FleNRf0ogV4Qj2dxgO4odbCif5xP+A71orNLCM383Yf64ow7eolynzOToC6FT reT2CwJ+Eee36b/rBZPti2d0QH9XQUUEphkRk4fmefY0TXZcOaep8nITJSQTa3gkpV2p 7H4Q== X-Gm-Message-State: AOAM533nqez4DOeEoBRLjcIv8+kQV7L5coNZqkep0/k7wvlnlb0YfgUX 4Bcg1Y5OgXXymnqOajXBIwTOCQtyOkY6UmN4V1fRTkw83nu2L137wTHwy0KcjLiPp4m2x0TbfsV QRCaZX7RHHlhBTNCpm39HcSN71KaAOhBb7ZgjhityXX5DWRLbk//j043dMvSeL1u2DA== X-Received: by 2002:ac8:5191:: with SMTP id c17mr30380617qtn.116.1605197002468; Thu, 12 Nov 2020 08:03:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKtbENkFhX1nUf8uC1vexPb9aMJfs6wJStMxhjT4NDlz01ukdJkJ9PnzNwY+7phqwVZgL4nA== X-Received: by 2002:ac8:5191:: with SMTP id c17mr30380573qtn.116.1605197002068; Thu, 12 Nov 2020 08:03:22 -0800 (PST) Received: from [192.168.1.148] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id l125sm5014849qkc.111.2020.11.12.08.03.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Nov 2020 08:03:21 -0800 (PST) Subject: Re: [PATCH] system: Add WARN_UNUSED_RESULT To: Marek Polacek , GCC Patches References: <20201112030348.2939013-1-polacek@redhat.com> From: Jason Merrill Message-ID: <0f7e03d3-c21d-dc37-36df-cde7dff80cad@redhat.com> Date: Thu, 12 Nov 2020 11:03:20 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201112030348.2939013-1-polacek@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-16.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2020 16:03:26 -0000 On 11/11/20 10:03 PM, Marek Polacek wrote: > I'd like to have the option of marking functions with > __attribute__ ((__warn_unused_result__)), so this patch adds a macro. > And use it for maybe_wrap_with_location, it's always a bug if the > return value is not used, which happened to me and got me confused. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? OK. > gcc/ChangeLog: > > * system.h (WARN_UNUSED_RESULT): Define for GCC >= 3.4. > * tree.h (maybe_wrap_with_location): Add WARN_UNUSED_RESULT. > --- > gcc/system.h | 6 ++++++ > gcc/tree.h | 2 +- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/gcc/system.h b/gcc/system.h > index b0f3f1dd019..6f6ab616a61 100644 > --- a/gcc/system.h > +++ b/gcc/system.h > @@ -789,6 +789,12 @@ extern void fancy_abort (const char *, int, const char *) > #define ALWAYS_INLINE inline > #endif > > +#if GCC_VERSION >= 3004 > +#define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) > +#else > +#define WARN_UNUSED_RESULT > +#endif > + > /* Use gcc_unreachable() to mark unreachable locations (like an > unreachable default case of a switch. Do not use gcc_assert(0). */ > #if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING > diff --git a/gcc/tree.h b/gcc/tree.h > index 684be10b440..9a713cdb0c7 100644 > --- a/gcc/tree.h > +++ b/gcc/tree.h > @@ -1214,7 +1214,7 @@ get_expr_source_range (tree expr) > extern void protected_set_expr_location (tree, location_t); > extern void protected_set_expr_location_if_unset (tree, location_t); > > -extern tree maybe_wrap_with_location (tree, location_t); > +WARN_UNUSED_RESULT extern tree maybe_wrap_with_location (tree, location_t); > > extern int suppress_location_wrappers; > > > base-commit: 0f5f9ed5e5a041b636cc002451b1e8b2295f8e4f >