]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/doc/invoke.texi
c++: Add support for -std={c,gnu}++2{c,6}
authorMarek Polacek <polacek@redhat.com>
Thu, 22 Jun 2023 20:56:26 +0000 (16:56 -0400)
committerMarek Polacek <polacek@redhat.com>
Fri, 23 Jun 2023 20:46:29 +0000 (16:46 -0400)
commit5388a43f6a3f348929292998bd6d0c1da6f006de
treedcc504a25f4e8ac3aedc9274918abc05d37f6984
parentb7fc0a3be52f78100a270b63e7555fde078fd2e3
c++: Add support for -std={c,gnu}++2{c,6}

It seems prudent to add C++26 now that the first C++26 papers have been
approved.  I followed commit r11-6920 as well as r8-3237.

Since C++23 is essentially finished and its __cplusplus value has
settled to 202302L, I've updated cpp_init_builtins and marked
-std=c++2b Undocumented and made -std=c++23 no longer Undocumented.

As for __cplusplus, I've chosen 202400L:

  $ xg++ -std=c++26 -dM -E -x c++ - < /dev/null | grep cplusplus
  #define __cplusplus 202400L

I've verified the patch with a simple test, exercising the new
directives.  Don't forget to update your GXX_TESTSUITE_STDS!

This patch does not add -Wc++26-extensions.

gcc/c-family/ChangeLog:

* c-common.h (cxx_dialect): Add cxx26 as a dialect.
* c-opts.cc (set_std_cxx26): New.
(c_common_handle_option): Set options when -std={c,gnu}++2{c,6} is
enabled.
(c_common_post_options): Adjust comments.
* c.opt: Add options for -std=c++26, std=c++2c, -std=gnu++26,
and -std=gnu++2c.
(std=c++2b): Mark as Undocumented.
(std=c++23): No longer Undocumented.

gcc/ChangeLog:

* doc/cpp.texi (__cplusplus): Document value for -std=c++26 and
-std=gnu++26.  Document that for C++23, its value is 202302L.
* doc/invoke.texi: Document -std=c++26 and -std=gnu++26.
* dwarf2out.cc (highest_c_language): Handle GNU C++26.
(gen_compile_unit_die): Likewise.

libcpp/ChangeLog:

* include/cpplib.h (c_lang): Add CXX26 and GNUCXX26.
* init.cc (lang_defaults): Add rows for CXX26 and GNUCXX26.
(cpp_init_builtins): Set __cplusplus to 202400L for C++26.
Set __cplusplus to 202302L for C++23.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_c++23): Return
1 also if check_effective_target_c++26.
(check_effective_target_c++23_down): New.
(check_effective_target_c++26_only): New.
(check_effective_target_c++26): New.
* g++.dg/cpp23/cplusplus.C: Adjust expected value.
* g++.dg/cpp26/cplusplus.C: New test.
gcc/c-family/c-common.h
gcc/c-family/c-opts.cc
gcc/c-family/c.opt
gcc/doc/cpp.texi
gcc/doc/invoke.texi
gcc/dwarf2out.cc
gcc/testsuite/g++.dg/cpp23/cplusplus.C
gcc/testsuite/g++.dg/cpp26/cplusplus.C [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp
libcpp/include/cpplib.h
libcpp/init.cc