Bump the value of __STDC_VERSION__ in -std=c2x mode

Previously, we reported the same value as for C17, now we report 202000L, which
is the same value currently used by GCC.

Once C23 ships, this value will be bumped to the correct date.
This commit is contained in:
Aaron Ballman 2021-10-17 09:22:29 -04:00
parent 052b77e49f
commit c8be7743ac
3 changed files with 12 additions and 1 deletions

View File

@ -129,6 +129,9 @@ Windows Support
C Language Changes in Clang
---------------------------
- The value of ``__STDC_VERSION__`` has been bumped to ``202000L`` when passing
``-std=c2x`` so that it can be distinguished from C17 mode. This value is
expected to change again when C23 is published.
- Wide multi-characters literals such as ``L'ab'`` that would previously be interpreted as ``L'b'``
are now ill-formed in all language modes. The motivation for this change is outlined in
`P2362 <wg21.link/P2362>`_.

View File

@ -371,7 +371,10 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
// value is, are implementation-defined.
// (Removed in C++20.)
if (!LangOpts.CPlusPlus) {
if (LangOpts.C17)
// FIXME: Use correct value for C23.
if (LangOpts.C2x)
Builder.defineMacro("__STDC_VERSION__", "202000L");
else if (LangOpts.C17)
Builder.defineMacro("__STDC_VERSION__", "201710L");
else if (LangOpts.C11)
Builder.defineMacro("__STDC_VERSION__", "201112L");

View File

@ -0,0 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x %s
// expected-no-diagnostics
// FIXME: Test the correct value once C23 ships.
_Static_assert(__STDC_VERSION__ > 201710L, "Incorrect __STDC_VERSION__");