On Tue, Sep 27, 2022 at 10:41:29AM +0200, Richard Biener wrote: > On Mon, Sep 26, 2022 at 9:54 PM Marek Polacek <pola...@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