From: Marek Polacek <polacek@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Jason Merrill <jason@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2] c++: Don't quote nothrow in diagnostic
Date: Tue, 27 Sep 2022 09:00:56 -0400 [thread overview]
Message-ID: <YzL0CKInS+D4Wn42@redhat.com> (raw)
In-Reply-To: <CAFiYyc2wkv+FdWGQeHOwUF5LkyYjHS55Y8NBtYVQXYhrSTm13g@mail.gmail.com>
On Tue, Sep 27, 2022 at 10:41:29AM +0200, Richard Biener wrote:
> On Mon, Sep 26, 2022 at 9:54 PM Marek Polacek <polacek@redhat.com> wrote:
> >
> > On Mon, Sep 26, 2022 at 12:34:04PM -0400, Jason Merrill wrote:
> > > On 9/26/22 03:50, Richard Biener wrote:
> > > > On Fri, Sep 23, 2022 at 8:41 PM Marek Polacek via Gcc-patches
> > > > <gcc-patches@gcc.gnu.org> wrote:
> > > > >
> > > > > In <https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602057.html>
> > > > > Jason noticed that we quote "nothrow" in diagnostics even though it's
> > > > > not a keyword in C++. Just removing the quotes didn't work because
> > > > > then -Wformat-diag complains, so this patch replaces it with "no-throw".
> > > > >
> > > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> > > >
> > > > That doesn't look like an improvement to me. Can we quote 'nothrow()' instead?
> >
> > Understood.
> >
> > > nothrow() is a syntax error; the C++11 keyword is 'noexcept'. std::nothrow
> > > is a dummy placement argument used to indicate that a new-expression should
> > > return null rather than throw on failure.
> > >
> > > But bizarrely, the library traits use the word "nothrow". Marek's patch
> > > clarifies that we are not trying to refer to anything in the language.
> > >
> > > > I'd rather leave it alone than changing it to no-throw. Why does -Wformat-diag
> > > > complain? If we shouldn't quote nothrow that should be adjusted?
> > >
> > > I think -Wformat-diag complains because "nothrow" is an attribute; it also
> > > includes some other attribute names in the list of "keywords".
> > >
> > > I would also be fine with just removing the quotes and removing nothrow from
> > > c_keywords.
> >
> > Like below? Bootstrapped/regtested on x86_64-pc-linux-gnu.
>
> Yes. I assume that terms like "nothrow constructible" are used in the
> C++ standard?
I don't really see that. [meta.unary.prop] says "known not to throw any
exceptions" for the _nothrow built-ins. That may be too long to use in
diagnostics. And the warning would probably complain about the unquoted
'throw' in it. :)
> > Note that now I see warnings with my system compiler (gcc-12.2.1). Can
> > I commit the c-format.cc hunk to gcc 12 so that eventually even gcc 12
> > stops warning?
>
> Sure.
Thanks.
Marek
next prev parent reply other threads:[~2022-09-27 13:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-23 18:40 [PATCH] " Marek Polacek
2022-09-26 7:50 ` Richard Biener
2022-09-26 16:34 ` Jason Merrill
2022-09-26 19:54 ` [PATCH v2] " Marek Polacek
2022-09-27 8:41 ` Richard Biener
2022-09-27 13:00 ` Marek Polacek [this message]
2022-09-27 13:19 ` 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=YzL0CKInS+D4Wn42@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--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).