]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libcpp: Adjust __STDC_VERSION__ for C23
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 Apr 2024 06:58:39 +0000 (08:58 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 30 Apr 2024 06:58:39 +0000 (08:58 +0200)
While the C23 standard isn't officially release yet,
in 2011 we've changed __STDC_VERSION__ value for C11 already
in the month in which the new __STDC_VERSION__ value has been
finalized, so we want to change this now or wait
until we implement all the C23 features?

Note, seems Clang up to 17 also used 202000L for -std=c2x but
Clang 18+ uses 202311L as specified in the latest C23 drafts.

2024-04-30  Jakub Jelinek  <jakub@redhat.com>

* init.cc (cpp_init_builtins): Change __STDC_VERSION__
for C23 from 202000L to 202311L.

* doc/cpp.texi (__STDC_VERSION__): Document 202311L value
for -std=c23/-std=gnu23.

gcc/doc/cpp.texi
libcpp/init.cc

index 3de6e7aa7378e0bc317eaea2053856b6b6c6ff94..3f38ca37feaf0697be4e3ac64873ec4df06ae281 100644 (file)
@@ -1886,8 +1886,8 @@ the 1999 revision of the C standard; the value @code{201112L}
 signifies the 2011 revision of the C standard; the value
 @code{201710L} signifies the 2017 revision of the C standard (which is
 otherwise identical to the 2011 version apart from correction of
-defects).  An unspecified value larger than @code{201710L} is used for
-the experimental @option{-std=c23} and @option{-std=gnu23} modes.
+defects).  The value @code{202311L} is used for the experimental
+@option{-std=c23} and @option{-std=gnu23} modes.
 
 This macro is not defined if the @option{-traditional-cpp} option is
 used, nor when compiling C++ or Objective-C@.
index 54fc9236d3801da9a0789bf402bae521f8a7a2fc..c457fa659e7b8ca43cbcaf92009dcd6b380a942a 100644 (file)
@@ -594,7 +594,7 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
     _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
   else if (CPP_OPTION (pfile, lang) == CLK_STDC23
           || CPP_OPTION (pfile, lang) == CLK_GNUC23)
-    _cpp_define_builtin (pfile, "__STDC_VERSION__ 202000L");
+    _cpp_define_builtin (pfile, "__STDC_VERSION__ 202311L");
   else if (CPP_OPTION (pfile, lang) == CLK_STDC17
           || CPP_OPTION (pfile, lang) == CLK_GNUC17)
     _cpp_define_builtin (pfile, "__STDC_VERSION__ 201710L");