This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ C++ ] [ PATCH ] [ RFC ] p1301 - [[nodiscard("should have a reason")]]


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]