public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Gallager <egall@gwmail.gwu.edu>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: Add new warning options for C++ language mismatches
Date: Wed, 19 May 2021 12:40:59 -0400	[thread overview]
Message-ID: <CAMfHzOs-EJ_pjfo7QMwv0xfbtWftGpzXxOvS2t8-KkFNXcbzUw@mail.gmail.com> (raw)
In-Reply-To: <YKU9uHbWUDossx0Q@redhat.com>

On Wed, May 19, 2021 at 12:33 PM Jonathan Wakely via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This adds new warning flags, enabled by default: -Wc++11-extensions,
> -Wc++14-extensions, -Wc++17-extensions, and -Wc++20-extensions. The
> names of the flags are copied from Clang, which already has similar
> options.
>
> No new diagnostics are added, but the new OPT_Wxxx variables are used to
> control existing pedwarns about occurences of new C++ constructs in code
> using an old C++ standard dialect. This allows several existing warnings
> that cannot currently be disabled to be controlled by the appropriate
> -Wno-xxx flag. For example, it will now be possible to disable warnings
> about using variadic templates in C++98 code, by using the new
> -Wno-c++11-extensions option. This will allow libstdc++ headers to
> disable those warnings unconditionally by using diagnostic pragmas, so
> that they are not emitted even if -Wsystem-headers is used.
>
> Some of the affected diagnostics are currently only given when
> -Wpedantic is used. Now that we have a more specific warning flag, we
> could consider making them not depend on -Wpedantic, and only on the new
> flag. This patch does not do that, as it intends to make no changes to
> what is accepted/rejected by default. The only effect should be that
> the new option is shown when -fdiagnostics-show-option is active, and
> that some warnings can be disabled by using the new flags (and for the
> warnings that previously only dependend on -Wpedantic, it will now be
> possible to disable just those warnings while still using -Wpedantic for
> its other benefits).
>
> A new helper function, warn_about_dialect_p, is introduced to avoid the
> repetition of `if (cxx_dialect < cxxNN && warn_cxxNN_extensions)`
> everywhere.
>
> gcc/c-family/ChangeLog:
>
>         * c.opt (Wc++11-extensions, Wc++14-extensions)
>         (Wc++17-extensions, Wc++20-extensions): New options.
>
> gcc/cp/ChangeLog:
>
>         * call.c (maybe_warn_array_conv): Use new function and option.
>         * cp-tree.h (warn_about_dialect_p): Declare new function.
>         * error.c (maybe_warn_cpp0x): Use new function and options.
>         (warn_about_dialect_p): Define new function.
>         * parser.c (cp_parser_unqualified_id): Use new function and
>         option.
>         (cp_parser_pseudo_destructor_name): Likewise.
>         (cp_parser_lambda_introducer): Likewise.
>         (cp_parser_lambda_declarator_opt): Likewise.
>         (cp_parser_init_statement): Likewise.
>         (cp_parser_decomposition_declaration): Likewise.
>         (cp_parser_function_specifier_opt): Likewise.
>         (cp_parser_static_assert): Likewise.
>         (cp_parser_namespace_definition): Likewise.
>         (cp_parser_initializer_list): Likewise.
>         (cp_parser_member_declaration): Likewise.
>         * pt.c (check_template_variable): Likewise.
>
> Tested x86_64-linux. OK for trunk?
>
>

Thank you for doing this! One thing I'm wondering about, is that I'm
pretty sure clang also allows at least some of these to be used with
plain C as well, for example for things like the old use of "auto" in
C conflicting with the newer C++11 meaning of "auto". Would it be
possible to do likewise for GCC as well? Just an idea.
Thanks,
Eric Gallager

  parent reply	other threads:[~2021-05-19 16:41 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 16:32 Jonathan Wakely
2021-05-19 16:39 ` Jonathan Wakely
2021-05-19 16:46   ` Jonathan Wakely
2021-05-19 17:26     ` Jason Merrill
2021-05-19 19:55       ` Jonathan Wakely
2021-05-19 20:05         ` Jonathan Wakely
2021-05-19 20:08           ` Jason Merrill
2021-05-19 22:52             ` Jonathan Wakely
2021-05-20 20:05               ` Jonathan Wakely
2021-05-21 16:10                 ` Jason Merrill
2021-05-19 20:05         ` Jason Merrill
2021-05-20 12:56           ` Jonathan Wakely
2021-05-20 16:34             ` Jason Merrill
2021-05-20 19:49               ` Jonathan Wakely
2021-05-20 17:25             ` Martin Sebor
2021-05-20 19:32               ` Jonathan Wakely
2021-05-19 16:53   ` Marek Polacek
2021-05-19 16:59     ` Jonathan Wakely
2021-05-19 17:09       ` Marek Polacek
2022-03-29  9:27         ` options, '-Wc++[...]-extensions': Remove undefined one-argument 'LangEnabledBy' option properties (was: [PATCH] c++: Add new warning options for C++ language mismatches) Thomas Schwinge
2022-03-29 11:34           ` Jonathan Wakely
2022-03-29 18:13           ` Joseph Myers
2021-05-19 17:51   ` [PATCH] c++: Add new warning options for C++ language mismatches Martin Sebor
2021-05-19 18:03     ` Marek Polacek
2021-05-19 18:35       ` Jonathan Wakely
2021-05-19 18:41         ` Marek Polacek
2021-05-19 23:05     ` Jonathan Wakely
2021-05-19 23:12     ` Jonathan Wakely
2021-05-19 16:40 ` Eric Gallager [this message]
2021-05-19 16:50   ` Jonathan Wakely
2021-05-19 16:56     ` Jonathan Wakely

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=CAMfHzOs-EJ_pjfo7QMwv0xfbtWftGpzXxOvS2t8-KkFNXcbzUw@mail.gmail.com \
    --to=egall@gwmail.gwu.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.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).