This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ C++ ] [ PATCH ] [ RFC ] p1301 - [[nodiscard("should have a reason")]]
- From: Jason Merrill <jason at redhat dot com>
- To: JeanHeyd Meneide <phdofthehouse at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Oct 2019 17:03:41 -0400
- Subject: Re: [ C++ ] [ PATCH ] [ RFC ] p1301 - [[nodiscard("should have a reason")]]
- References: <CANHA4Oi=_wi0nFhMfmomPr4hgcLEYftVgs08D3Awcg6m0Hdmow@mail.gmail.com>
On 10/15/19 8:31 PM, JeanHeyd Meneide wrote:
Attached is a patch for p1301 that improves in the way Jason Merrill
specified earlier
(https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00858.html)
Great, thanks!
This mail is missing ChangeLog entries. My guess is that you're using
git diff to create the patch file; git show or (even better) git
format-patch will also include the commit message.
+/* Check that the attribute ATTRIBU,TE appears at most once in the
Stray added ,
- else if (TREE_CODE (expr) == TARGET_EXPR
- && lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (type)))
+ else if (TREE_CODE (expr) == TARGET_EXPR)
{
/* The TARGET_EXPR confuses do_warn_unused_result into thinking that the
result is used, so handle that case here. */
- if (fn)
+ if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (type)))
...
+ else if ((attr = lookup_attribute ("nodiscard", TYPE_ATTRIBUTES (type))))
The first two if/else should have already handled nodiscard; this else
was only intended to handle cases where warn_unused_result wants a
warning and nodiscard doesn't, i.e. when there's an explicit cast to
void. We shouldn't need to change anything here.
Jason