public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: Fix bogus -Wparentheses warning [PR95344]
Date: Thu, 28 May 2020 17:01:51 -0400	[thread overview]
Message-ID: <a65af333-e0e8-88b6-b422-c479b95f2f14@redhat.com> (raw)
In-Reply-To: <20200527002541.546573-1-polacek@redhat.com>

On 5/26/20 8:25 PM, Marek Polacek wrote:
> Since r267272, which added location wrappers, cp_fold loses
> TREE_NO_WARNING on a MODIFY_EXPR that finish_parenthesized_expr set, and
> that results in a bogus -Wparentheses warning.
> 
> I.e., previously we had "b = 1" but now we have "VIEW_CONVERT_EXPR<bool>(b) = 1"
> and cp_fold_maybe_rvalue folds away the location wrapper and so we do
> 2718             x = fold_build2_loc (loc, code, TREE_TYPE (x), op0, op1);
> in cp_fold and the flag is lost.
> 
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/10/9?
> 
> 	PR c++/95344
> 	* cp-gimplify.c (cp_fold) <case MODIFY_EXPR>: Set TREE_NO_WARNING.
> 
> 	* c-c++-common/Wparentheses-2.c: New test.
> ---
>   gcc/cp/cp-gimplify.c                        |  5 ++++-
>   gcc/testsuite/c-c++-common/Wparentheses-2.c | 18 ++++++++++++++++++
>   2 files changed, 22 insertions(+), 1 deletion(-)
>   create mode 100644 gcc/testsuite/c-c++-common/Wparentheses-2.c
> 
> diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
> index 53d715dcd89..8b505dd878c 100644
> --- a/gcc/cp/cp-gimplify.c
> +++ b/gcc/cp/cp-gimplify.c
> @@ -2745,7 +2745,10 @@ cp_fold (tree x)
>   	    x = org_x;
>   	}
>         if (code == MODIFY_EXPR && TREE_CODE (x) == MODIFY_EXPR)
> -	TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x);
> +	{
> +	  TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x);
> +	  TREE_NO_WARNING (x) = TREE_NO_WARNING (org_x);
> +	}

I wonder if we want to copy these flags lower down for any EXPR_P (x) 
where TREE_CODE (x) == code?

Jason


  reply	other threads:[~2020-05-28 21:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27  0:25 Marek Polacek
2020-05-28 21:01 ` Jason Merrill [this message]
2020-05-28 23:11   ` [PATCH v2] " Marek Polacek
2020-05-29 16:30     ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a65af333-e0e8-88b6-b422-c479b95f2f14@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=polacek@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).