From: Jason Merrill <jason@redhat.com>
To: Martin Sebor <msebor@gmail.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] avoid -Wredundant-tags on a first declaration in use (PR 93824)
Date: Fri, 28 Feb 2020 20:24:00 -0000 [thread overview]
Message-ID: <2698a399-4176-2b5f-a134-52a0d82c2121@redhat.com> (raw)
In-Reply-To: <65013bfc-23c3-47fb-a58d-9ab802d1febb@gmail.com>
On 2/28/20 12:45 PM, Martin Sebor wrote:
> On 2/28/20 9:58 AM, Jason Merrill wrote:
>> On 2/24/20 6:58 PM, Martin Sebor wrote:
>>> -Wredundant-tags doesn't consider type declarations that are also
>>> the first uses of the type, such as in 'void f (struct S);' and
>>> issues false positives for those. According to the reported that's
>>> making it harder to use the warning to clean up LibreOffice.
>>>
>>> The attached patch extends -Wredundant-tags to avoid these false
>>> positives by relying on the same class_decl_loc_t::class2loc mapping
>>> as -Wmismatched-tags. The patch also somewhat improves the detection
>>> of both issues in template declarations (though more work is still
>>> needed there).
>>
>>> + a new entry for it and return unless it's a declaration
>>> + involving a template that may need to be diagnosed by
>>> + -Wredundant-tags. */
>>> *rdl = class_decl_loc_t (class_key, false, def_p);
>>> - return;
>>> + if (TREE_CODE (decl) != TEMPLATE_DECL)
>>> + return;
>>
>> How can the first appearance of a class template be redundant?
>
> I'm not sure I correctly understand the question. The comment says
> "involving a template" (i.e., not one of the first declaration of
> a template). The test case that corresponds to this test is:
>
> template <class> struct S7 { };
> struct S7<void> s7v; // { dg-warning "\\\[-Wredundant-tags" }
>
> where DECL is the TEPLATE_DECL of S7<void>.
>
> As I mentioned, more work is still needed to handle templates right
> because some redundant tags are still not diagnosed. For example:
>
> template <class> struct S7 { };
> template <class T>
> using U = struct S7<T>; // missing warning
When we get here for an instance of a template, it doesn't make sense to
treat it as a new type.
If decl is a template and type_decl is an instance of that template, do
we want to (before the lookup) change type_decl to the template or the
corresponding generic TYPE_DECL, which should already be in the table?
Jason
next prev parent reply other threads:[~2020-02-28 20:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 23:58 Martin Sebor
2020-02-28 16:59 ` Jason Merrill
2020-02-28 17:45 ` Martin Sebor
2020-02-28 20:24 ` Jason Merrill [this message]
2020-03-09 16:31 ` Martin Sebor
2020-03-09 19:40 ` Jason Merrill
2020-03-09 21:39 ` Martin Sebor
2020-03-10 0:08 ` Jason Merrill
2020-03-11 16:57 ` Martin Sebor
2020-03-11 20:10 ` Jason Merrill
2020-03-11 21:30 ` Martin Sebor
2020-03-12 17:03 ` Martin Sebor
2020-03-12 22:38 ` Martin Sebor
2020-03-18 22:09 ` [PING][PATCH] " Martin Sebor
2020-03-19 3:07 ` [PATCH] " Jason Merrill
2020-03-19 23:55 ` Martin Sebor
2020-03-20 21:53 ` Jason Merrill
2020-03-21 21:59 ` Martin Sebor
2020-03-23 14:49 ` Jason Merrill
2020-03-23 16:50 ` Martin Sebor
2020-03-26 5:36 ` Jason Merrill
2020-03-26 18:58 ` Martin Sebor
2020-03-26 22:16 ` Jason Merrill
2020-03-26 22:51 ` Martin Sebor
2020-03-27 16:33 ` Jason Merrill
2020-03-25 20:54 ` Martin Sebor
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=2698a399-4176-2b5f-a134-52a0d82c2121@redhat.com \
--to=jason@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).