public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Martin Sebor <msebor@gmail.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 0/11] warning control by group and location (PR 74765)
Date: Mon, 24 May 2021 19:08:14 -0400	[thread overview]
Message-ID: <47d06c821a53f5bd2246f0fca2c9a693bff6b882.camel@redhat.com> (raw)
In-Reply-To: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com>

On Mon, 2021-05-24 at 16:02 -0600, Martin Sebor wrote:
> Having just one bit control whether an expression or statement should
> be allowed to trigger warnings has been a source of bug reports about
> false negatives for years.  PR 74765 has a representative test case
> that shows how by setting the bit to avoid -Wparentheses the C++ front
> end also ends up preventing valid -Wuninitialized in the middle end,

For reference, PR 74765 has:

int foo(int x, int y)
{
    int i;
    if ((i ==0)) return x;
    return y;
}

int foo2(int x, int y)
{
    int i;
    if (i ==0) return x;
    return y;
}

where both fns have an uninitialized use of "i", but the double-parens
in "foo" have already been warned about, so TREE_NO_WARNING is set,
hence we don't get an uninit warning, right?

> but there are other such reports for C (e.g., PR 74762) as well as
> the middle end.


> This patch series solves the problem by associating an expression
> (whether a tree node or a GIMPLE statement) with more than one such
> bit through its location.  Each new bit in the mapping corresponds
> to a group of warnings (e.g., lexical, access, etc.), and each
> location may be associated with a simple bitmap with one bit for
> each group.  The initial groups are mostly ad hoc and should be
> refined over time.

The overall idea looks promising, thanks.

I didn't see any test cases in the patch kit; do you have some that
demonstrate the fixes for the above PRs?

I'm slightly nervous that, although we're gaining granularity in terms
of the different categories of warning, do we risk losing granularity
due to expressions sharing locations?

>   The rare expressions that have no location
> continue to have just one bit[1].

Where does this get stored?  I see the final patch in the kit removes
TREE_NO_WARNING, but I don't quite follow the logic for where the bit
would then be stored for an expr with UNKNOWN_LOCATION.

> 
> The first patch introduces three new APIs without making use of them
> in existing code:
> 
>    bool get_no_warning (..., int option);
>    void set_no_warning (..., int option, ...);
>    void copy_no_warning (...);

Is it possible to use "enum opt_code" (from the generated options.h)
rather than a plain "int" for these?  Or is this not available
everywhere we use these?

> 
> Subsequent patches then replace invocations of the TREE_NO_WARNING()
> macro and the gimple_no_warning_p() and gimple_set_no_warning()
> functions throughout GCC with those and remove the legacy APIs to
> keep them from being accidentally reintroduced along with the
> problem.
> These are mostly mechanical changes, except that most of the new
> invocations also specify the option whose disposition to query for
> the expression or location, or which to enable or disable[2].
> The last function, copy_no_warning(), copies the disposition from
> one expression or location to another.
> 
> A couple of design choices might be helpful to explain:
> 
> First, introducing "warning groups" rather than controlling each
> individual warning is motivated by a) the fact that the latter
> would make avoiding redundant warnings for related problems
> cumbersome (e.g., after issuing a -Warray-bounds we want to
> suppress -Wstringop-overflow as well -Wstringop-overread for
> the same access and vice versa), and b) simplicity and efficiency
> of the implementation (mapping each option would require a more
> complex data structure like a bitmap).
> 
> Second, using location_t to associate expressions/statements with
> the warning groups also turns out to be more useful in practice
> than a direct association between a tree or gimple*, and also
> simplifies managing the data structure.  Trees and gimple* come
> and go across passes, and maintaining a mapping for them that
> accounts for the possibility of them being garbage-collected
> and the same addresses reused is less than straightforward.

I find some of the terminology rather awkard due to it the negation
we're already using with TREE_NO_WARNING, in that we're turning on a
no_warning flag, and that this is a per-location/expr/stmt thing that's
different from the idea of enabling/disabling a specific warning
altogether (and the pragmas that control that).   Sometimes the patches
refer to enabling/disabling warnings and I think I want "enabling" and
"disabling" to mean the thing the user does with -Wfoo and -Wno-foo.

Would calling it a "warning suppression" or somesuch be more or less
klunky?

> 
> Martin
> 
> [1] My expectation is to work toward providing locations for all
> expressions/statements, even if it's the opening or closing brace
> of the function they're used in.)
> 
> [2] A number of {get,set}_no_warning() calls introduced by the patch
> don't provide an option argument and query or set just the one bit in
> the expression/statement.  Some of these may be correct as they are,
> but others could be refined to also specify an option.  I can do that
> in a follow-up patch if someone helps me find the right option.


Hope this is constructive
Dave


  parent reply	other threads:[~2021-05-24 23:08 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 22:02 Martin Sebor
2021-05-24 22:07 ` [PATCH 1/11] introduce xxx_no_warning APIs Martin Sebor
2021-05-24 22:09   ` [PATCH 2/11] use xxx_no_warning APIs in Ada Martin Sebor
2021-05-25  8:59     ` Eric Botcazou
2021-05-27 20:29       ` Martin Sebor
2021-05-24 22:10   ` [PATCH 3/11] use xxx_no_warning APIs in C Martin Sebor
2021-05-24 22:11   ` [PATCH 4/11] use xxx_no_warning APIs in C family Martin Sebor
2021-05-24 22:11   ` [PATCH 5/11] use xxx_no_warning APIs in C++ Martin Sebor
2021-05-24 22:12   ` [PATCH 6/11] use xxx_no_warning APIs in Fortran Martin Sebor
2021-05-24 22:13   ` [PATCH 7/11] " Martin Sebor
2021-05-24 22:14   ` [PATCH 8/11] use xxx_no_warning APIs in Objective-C Martin Sebor
2021-05-25 14:01     ` Iain Sandoe
2021-05-25 15:48       ` Martin Sebor
2021-05-25 15:56         ` Iain Sandoe
2021-05-24 22:15   ` [PATCH 9/11] use xxx_no_warning APIs in rl78 back end Martin Sebor
2021-05-24 22:16   ` [PATCH 10/11] use xxx_no_warning APIs in libcc1 Martin Sebor
2021-05-24 22:16   ` [PATCH 11/11] use xxx_no_warning APIs in the middle end Martin Sebor
2021-05-24 23:08     ` David Malcolm
2021-05-25  0:44       ` Martin Sebor
2021-05-24 23:08 ` David Malcolm [this message]
2021-05-25  0:42   ` [PATCH 0/11] warning control by group and location (PR 74765) Martin Sebor
2021-05-25  9:04     ` Richard Biener
2021-05-25 20:50       ` Martin Sebor
2021-05-27 11:19     ` Richard Sandiford
2021-05-27 16:41       ` Martin Sebor
2021-05-27 21:55         ` David Malcolm
2021-05-28  4:40           ` Jason Merrill
2021-06-04 21:27   ` [PATCH 0/13] v2 " Martin Sebor
2021-06-04 21:41     ` [PATCH 1/13] v2 [PATCH 1/13] Add support for per-location warning groups " Martin Sebor
2021-06-21 21:34       ` [PING][PATCH " Martin Sebor
2021-06-22 23:18       ` [PATCH " David Malcolm
2021-06-22 23:28         ` David Malcolm
2021-06-23 19:47           ` Martin Sebor
2021-06-24  5:26             ` Jeff Law
2021-06-25  1:34               ` Martin Sebor
2021-09-01 19:35             ` Thomas Schwinge
2021-09-02  0:14               ` Martin Sebor
2021-09-03 19:16                 ` Thomas Schwinge
2021-09-10  7:45                   ` [PING] Don't maintain a warning spec for 'UNKNOWN_LOCATION'/'BUILTINS_LOCATION' [PR101574] (was: [PATCH 1/13] v2 [PATCH 1/13] Add support for per-location warning groups (PR 74765)) Thomas Schwinge
2021-09-13 14:00                     ` Jeff Law
2021-11-09 14:18                   ` Use 'location_hash' for 'gcc/diagnostic-spec.h:nowarn_map' " Thomas Schwinge
2021-11-15 15:01                     ` [ping] Use 'location_hash' for 'gcc/diagnostic-spec.h:nowarn_map' Thomas Schwinge
2021-11-15 16:43                       ` Martin Sebor
2021-11-09 10:28                 ` Get rid of infinite recursion for 'typedef' used with GTY-marked 'gcc/diagnostic-spec.h:nowarn_map' [PR101204] (was: [PATCH 1/13] v2 [PATCH 1/13] Add support for per-location warning groups (PR 74765)) Thomas Schwinge
2021-11-09 10:54                   ` Richard Biener
2021-11-09 12:25                     ` Get rid of infinite recursion for 'typedef' used with GTY-marked 'gcc/diagnostic-spec.h:nowarn_map' [PR101204, PR103157] Thomas Schwinge
2021-11-10  4:52                   ` Get rid of infinite recursion for 'typedef' used with GTY-marked 'gcc/diagnostic-spec.h:nowarn_map' [PR101204] Martin Sebor
2021-11-24 10:28                     ` 'gengtype' (was: Get rid of infinite recursion for 'typedef' used with GTY-marked 'gcc/diagnostic-spec.h:nowarn_map' [PR101204]) Thomas Schwinge
2021-06-04 21:41     ` [PATCH 2/13] v2 Use new per-location warning APIs in Ada Martin Sebor
2021-06-24  5:07       ` Jeff Law
2021-06-28 21:20         ` Martin Sebor
2021-06-04 21:41     ` [PATCH 3/13] v2 Use new per-location warning APIs in C front end Martin Sebor
2021-06-21 21:35       ` [PING][PATCH " Martin Sebor
2021-06-24  5:09       ` [PATCH " Jeff Law
2021-06-25  1:35         ` Martin Sebor
2021-06-04 21:42     ` [PATCH 4/13] v2 Use new per-location warning APIs in C family code Martin Sebor
2021-06-21 21:35       ` [PING][PATCH " Martin Sebor
2021-06-24  5:06       ` [PATCH " Jeff Law
2021-06-25  1:36         ` Martin Sebor
2021-06-04 21:42     ` [PATCH 5/13] v2 Use new per-location warning APIs in the RL78 back end Martin Sebor
2021-06-24  5:06       ` Jeff Law
2021-06-04 21:42     ` [PATCH 6/13] v2 Use new per-location warning APIs in the C++ front end Martin Sebor
2021-06-21 21:37       ` [PING][PATCH " Martin Sebor
2021-06-24  5:12       ` [PATCH " Jeff Law
2021-06-25  1:38         ` Martin Sebor
2021-06-04 21:42     ` [PATCH 7/13] v2 Use new per-location warning APIs in the FORTRAN " Martin Sebor
2021-06-21 21:42       ` [PING][PATCH " Martin Sebor
2021-06-24  5:05       ` [PATCH " Jeff Law
2021-06-28 21:21         ` Martin Sebor
2021-06-04 21:42     ` [PATCH 8/13] v2 Use new per-location warning APIs in libcc1 Martin Sebor
2021-06-24  5:04       ` Jeff Law
2021-06-28 21:22         ` Martin Sebor
2021-06-04 21:43     ` [PATCH 9/13] v2 Use new per-location warning APIs in LTO Martin Sebor
2021-06-21 21:54       ` [PING][PATCH " Martin Sebor
2021-06-24  9:32         ` Richard Biener
2021-06-24 15:27           ` Martin Sebor
2021-06-25  7:46             ` Richard Biener
2021-06-24  5:03       ` [PATCH " Jeff Law
2021-06-04 21:43     ` [PATCH 10/13] v2 Use new per-location warning APIs in the middle end Martin Sebor
2021-06-21 21:58       ` [PING][PATCH " Martin Sebor
2021-06-24  5:15       ` [PATCH " Jeff Law
2021-06-25  1:40         ` Martin Sebor
2021-06-04 21:43     ` [PATCH 11/13] v2 Use new per-location warning APIs in the Objective-C front end Martin Sebor
2021-06-24  5:02       ` Jeff Law
2021-06-28 21:22         ` Martin Sebor
2021-06-04 21:43     ` [PATCH 12/13] v2 Remove TREE_NO_WARNING and gimple*no_warning* APIs Martin Sebor
2021-06-24  5:01       ` Jeff Law
2021-06-04 21:43     ` [PATCH 13/13] v2 Add regression tests for PR 74765 and 74762 Martin Sebor
2021-06-24  4:56       ` Jeff Law
2021-06-28 21:23         ` Martin Sebor
2021-06-15  1:29     ` [PING][PATCH 0/13] v2 warning control by group and location (PR 74765) Martin Sebor
2021-07-17 20:36     ` [PATCH " Jan-Benedict Glaw
2021-07-19 15:08       ` Martin Sebor
2021-07-28 11:14         ` Andrew Burgess
2021-07-28 16:16           ` Martin Sebor
2021-07-29  8:26             ` Andrew Burgess
2021-07-29 14:41               ` Martin Sebor
2021-05-30  2:06 ` [PATCH 0/11] " Jeff Law

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=47d06c821a53f5bd2246f0fca2c9a693bff6b882.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@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).