public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/106111] -Wc++20-compat doesn't warn about using `requires` as an identifier
Date: Tue, 28 Jun 2022 09:53:25 +0000	[thread overview]
Message-ID: <bug-106111-4-6Ivth8V5sf@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106111-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106111

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oh, that's because -Wc++20-compat doesn't include -Wc++17-compat etc.

With the right options GCC warns about three:

$ g++ -std=c++03 r.C -c -Wc++20-compat -Wc++11-compat -Wc++14-compat
-Wc++17-compat
r.C:1:5: warning: identifier ‘decltype’ is a keyword in C++11 [-Wc++11-compat]
    1 | int decltype, constexpr, consteval, requires, noexcept, alignof,
alignas;
      |     ^~~~~~~~
r.C:1:15: warning: identifier ‘constexpr’ is a keyword in C++11
[-Wc++11-compat]
    1 | int decltype, constexpr, consteval, requires, noexcept, alignof,
alignas;
      |               ^~~~~~~~~
r.C:1:47: warning: identifier ‘noexcept’ is a keyword in C++11 [-Wc++11-compat]
    1 | int decltype, constexpr, consteval, requires, noexcept, alignof,
alignas;
      |                                               ^~~~~~~~

We're missing warnings for alignof and alignas in C++11, and consteval and
requires in C++20.

Clang warns about them all:

$ clang++ -std=c++03 r.C -c -Wc++20-compat -Wc++11-compat -Wc++14-compat
-Wc++17-compat
r.C:1:5: warning: 'decltype' is a keyword in C++11 [-Wc++11-compat]
int decltype, constexpr, consteval, requires, noexcept, alignof, alignas;
    ^
r.C:1:15: warning: 'constexpr' is a keyword in C++11 [-Wc++11-compat]
int decltype, constexpr, consteval, requires, noexcept, alignof, alignas;
              ^
r.C:1:26: warning: 'consteval' is a keyword in C++20 [-Wc++20-compat]
int decltype, constexpr, consteval, requires, noexcept, alignof, alignas;
                         ^
r.C:1:37: warning: 'requires' is a keyword in C++20 [-Wc++20-compat]
int decltype, constexpr, consteval, requires, noexcept, alignof, alignas;
                                    ^
r.C:1:47: warning: 'noexcept' is a keyword in C++11 [-Wc++11-compat]
int decltype, constexpr, consteval, requires, noexcept, alignof, alignas;
                                              ^
r.C:1:57: warning: 'alignof' is a keyword in C++11 [-Wc++11-compat]
int decltype, constexpr, consteval, requires, noexcept, alignof, alignas;
                                                        ^
r.C:1:66: warning: 'alignas' is a keyword in C++11 [-Wc++11-compat]
int decltype, constexpr, consteval, requires, noexcept, alignof, alignas;
                                                                 ^
7 warnings generated.

  parent reply	other threads:[~2022-06-28  9:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  9:48 [Bug c++/106111] New: " redi at gcc dot gnu.org
2022-06-28  9:51 ` [Bug c++/106111] " redi at gcc dot gnu.org
2022-06-28  9:53 ` redi at gcc dot gnu.org [this message]
2022-06-28 12:16 ` mpolacek at gcc dot gnu.org
2022-06-28 12:20 ` mpolacek at gcc dot gnu.org
2022-06-28 12:24 ` mpolacek at gcc dot gnu.org
2022-07-01 15:11 ` cvs-commit at gcc dot gnu.org
2022-07-01 15:20 ` mpolacek at gcc dot gnu.org
2022-10-22  2:22 ` pinskia at gcc dot gnu.org

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=bug-106111-4-6Ivth8V5sf@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).