On Fri, Jan 08, 2021 at 12:48:51AM +0000, Paul Fee via Gcc-patches wrote:
> Derived from the changes that added C++2a support in 2017.
> https://gcc.gnu.org/g:026a79f70cf33f836ea5275eda72d4870a3041e5
> 
> No C++2b features are added here.
> Use of -std=c++2b sets __cplusplus to 202101L.

What Jon wrote, plus:

> 
> 
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 5541e694bb3..3a0d452b62b 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,10 @@
> +2021-01-08  Paul Fee  <paul.f....@gmail.com>
> +
> +    Add support for -std=c++2b
> +    * doc/cpp.texi (__cplusplus): Document value for -std=c++2b
> +    or -std=gnu+2b.

One plus missing above.

> --- a/gcc/c-family/c-common.h
> +++ b/gcc/c-family/c-common.h
> @@ -738,7 +738,9 @@ enum cxx_dialect {
>    /* C++17 */
>    cxx17,
>    /* C++20 */
> -  cxx20
> +  cxx20,
> +  /* C++23? */

In the past we used
  /* C++2a (C++20?) */
here, so perhaps
  /* C++2b (C++23?) */
?
> +  cxx2b

> 
> +/* Set the C++ 2020 standard (without GNU extensions if ISO).  */

2020 is wrong.  In the past we used
/* Set the C++ 202a draft standard (without GNU extensions if ISO).  */
so perhaps
/* Set the C++ 202b draft standard (without GNU extensions if ISO).  */

> +static void
> +set_std_cxx2b (int iso)
> +{
> +    cpp_set_lang (parse_in, iso ? CLK_CXX2B: CLK_GNUCXX2B);

Wrong formatting, only 2 char indentation for the whole function body.
> +    flag_no_gnu_keywords = iso;
> +    flag_no_nonansi_builtin = iso;
> +    flag_iso = iso;
> +    /* C++2b includes the C11 standard library.  */
> +    flag_isoc94 = 1;
> +    flag_isoc99 = 1;
> +    flag_isoc11 = 1;
> +    /* C++2b includes coroutines.  */
> +    flag_coroutines = true;
> +    cxx_dialect = cxx2b;
> +    lang_hooks.name = "GNU C++20"; /* Pretend C++20 until standardization.  
> */
> +}
> +
>  /* Args to -d specify what to dump.  Silently ignore
>     unrecognized options; they may be aimed at toplev.c.  */
>  static void
> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
> index 1766364806e..3464d72591b 100644
> --- a/gcc/c-family/c.opt
> +++ b/gcc/c-family/c.opt
> @@ -2214,6 +2214,11 @@ std=c++20
>  C++ ObjC++
>  Conform to the ISO 2020 C++ draft standard (experimental and
> incomplete support).
> 
> +std=c++2b
> +C++ ObjC++
> +Conform to the ISO 2023 (?) C++ draft standard (experimental and
> +incomplete support).

Perhaps no space before (?) ?
And to be consistent with other similar entries, there was no line wrapping in
the description.

> +
>  std=c11
>  C ObjC
>  Conform to the ISO 2011 C standard.
> @@ -2292,6 +2297,11 @@ std=gnu++20
>  C++ ObjC++
>  Conform to the ISO 2020 C++ draft standard with GNU extensions
> (experimental and incomplete support).
> 
> +std=gnu++2b
> +C++ ObjC++
> +Conform to the ISO 2023 (?) C++ draft standard with GNU extensions

Likewise.

> (experimental
> +and incomplete support).

> +    * lib/target-supports.exp: (check_effective_target_c++2a_only)
> +    rename to check_effective_target_c++20_only.

The : belongs after ), and description after : should start with capital
letter.  So
        * lib/target-supports.exp (check_effective_target_c++2a_only):
        Rename to ...
        (check_effective_target_c++20_only): ... this.
Though, what you are really doing is swapping the names of the two.

Also, while your patch keeps lang_name as GNU C++20 even for -std=c++2b,
I think it would be better to adjust dwarf2out.c too:
          else if (strcmp (language_string, "GNU C++17") == 0
                   || strcmp (language_string, "GNU C++20") == 0)
            /* For now.  */
            language = DW_LANG_C_plus_plus_14;
and add there || strcmp (language_string, "GNU C++23") == 0
so that we don't forget.

        Jakub

Reply via email to