public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>,
	Eric Botcazou <botcazou@adacore.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Do not erase warning data in gimple_set_location
Date: Mon, 13 Jun 2022 09:39:26 -0600	[thread overview]
Message-ID: <613be265-a85f-382d-94f8-1168b552a713@redhat.com> (raw)
In-Reply-To: <CAFiYyc0QhXatqni3ibge8aBzPp29niBsPeXYv1qpzhBN+6UwPQ@mail.gmail.com>

On 6/13/22 05:15, Richard Biener wrote:
> On Fri, Jun 10, 2022 at 12:58 PM Eric Botcazou via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> Hi,
>>
>> gimple_set_location is mostly invoked on newly built GIMPLE statements, so
>> their location is UNKNOWN_LOCATION and setting it will clobber the warning
>> data of the passed location, if any.
> 
> Hmm, I think instead of special-casing UNKNOWN_LOCATION
> what gimple_set_location should probably do is either not copy
> warnings at all or union them.  Btw, gimple_set_location also
> removes a previously set BLOCK (but gimple_set_block preserves
> the location locus and diagnostic override).
> 
> So I'd be tempted to axe the copy_warning () completely here.  Martin,
> there were
> probably cases that warranted it - do you remember anything specific here?

Nothing specific, just that the assumption behind the warning group
design was that a location must exist in order to suppress a warning
(a location is one of the first things that's set early on by the FE
and it makes little sense to issue a warning without one).

There was and in all likelihood still is code sets TREE_NO_WARNING
or gimple_no_warning on new trees/statements before setting their
location.  That interferes with the design when the new tree or
statement is meant to be a replacement of another.  I fixed a few
cases like that to set the location first but didn't have a way
of finding all such instances.  My expectation was to over time
change GCC to make sure a location would always be set before
the no-warning bit, and asserting that on every call to these
routines.  Adding tests like in the patch below goes in the opposite
direction and effectively papers over the problem.  I can't think
of a way to make the suppression work completely reliably without
ensuring that a location is always set before suppressing
a warning.

Martin

> 
> Thanks,
> Richard.
> 
>> Tested on x86-64/Linux, OK for mainline and 12 branch?
>>
>>
>> 2022-06-10  Eric Botcazou  <ebotcazou@adacore.com>
>>
>>          * gimple.h (gimple_set_location): Do not copy warning data from
>>          the previous location when it is UNKNOWN_LOCATION.
>>
>>
>> 2022-06-10  Eric Botcazou  <ebotcazou@adacore.com>
>>
>> testsuite/
>>          * c-c++-common/nonnull-1.c: Remove XFAIL for C++.
>>
>> --
>> Eric Botcazou
> 


  reply	other threads:[~2022-06-13 15:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10 10:57 Eric Botcazou
2022-06-12 15:38 ` Jeff Law
2022-06-13 11:15 ` Richard Biener
2022-06-13 15:39   ` Martin Sebor [this message]
2022-06-14 10:49   ` Eric Botcazou
2022-06-14 13:33     ` Richard Biener

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=613be265-a85f-382d-94f8-1168b552a713@redhat.com \
    --to=msebor@redhat.com \
    --cc=botcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.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).