OK.
On Fri, Sep 15, 2017 at 8:49 AM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > On Thu, Sep 14, 2017 at 11:28:09PM +0200, Jakub Jelinek wrote: >> > I'd be tempted to say leave all this, and march 1z -> 2a for the _next_ >> > standard. 2020 or so is a good first stab at the date. >> >> I didn't want to add c++2a and gnu++2a in the same patch, it can be added >> incrementally and readd the above wording. Unless somebody else is planning >> to do that, I can do that next. > > Here is so far untested incremental patch on top of the 1z -> 17 patch, > mostly using Andrew's patch, but adjusted so that it applies and with > various additions and small tweaks. > > 2017-09-15 Andrew Sutton <andrew.n.sut...@gmail.com> > Jakub Jelinek <ja...@redhat.com> > > Add support for -std=c++2a. > * c-common.h (cxx_dialect): Add cxx2a as a dialect. > * opt.c: Add options for -std=c++2a and -std=gnu++2a. > * c-opts.c (set_std_cxx2a): New. > (c_common_handle_option): Set options when -std=c++2a is enabled. > (c_common_post_options): Adjust comments. > (set_std_cxx14, set_std_cxx17): Likewise. > > * doc/cpp.texi (__cplusplus): Document value for -std=c++2a > or -std=gnu+2a. > * doc/invoke.texi: Document -std=c++2a and -std=gnu++2a. > > * lib/target-supports.exp (check_effective_target_c++17): Return > 1 also if check_effective_target_c++2a. > (check_effective_target_c++17_down): New. > (check_effective_target_c++2a_only): New. > (check_effective_target_c++2a): New. > * g++.dg/cpp2a/cplusplus.C: New. > > * include/cpplib.h (c_lang): Add CXX2A and GNUCXX2A. > * init.c (lang_defaults): Add rows for CXX2A and GNUCXX2A. > (cpp_init_builtins): Set __cplusplus to 201709L for C++2a. > > --- gcc/c-family/c-common.h.jj 2017-09-14 22:53:34.977313456 +0200 > +++ gcc/c-family/c-common.h 2017-09-15 12:59:25.539053983 +0200 > @@ -703,7 +703,9 @@ enum cxx_dialect { > /* C++14 */ > cxx14, > /* C++17 */ > - cxx17 > + cxx17, > + /* C++2a (C++20?) */ > + cxx2a > }; > > /* The C++ dialect being used. C++98 is the default. */ > --- gcc/c-family/c-opts.c.jj 2017-09-14 22:53:34.978313443 +0200 > +++ gcc/c-family/c-opts.c 2017-09-15 14:28:21.287595277 +0200 > @@ -111,6 +111,7 @@ static void set_std_cxx98 (int); > static void set_std_cxx11 (int); > static void set_std_cxx14 (int); > static void set_std_cxx17 (int); > +static void set_std_cxx2a (int); > static void set_std_c89 (int, int); > static void set_std_c99 (int); > static void set_std_c11 (int); > @@ -637,6 +638,12 @@ c_common_handle_option (size_t scode, co > set_std_cxx17 (code == OPT_std_c__17 /* ISO */); > break; > > + case OPT_std_c__2a: > + case OPT_std_gnu__2a: > + if (!preprocessing_asm_p) > + set_std_cxx2a (code == OPT_std_c__2a /* ISO */); > + break; > + > case OPT_std_c90: > case OPT_std_iso9899_199409: > if (!preprocessing_asm_p) > @@ -938,7 +945,7 @@ c_common_post_options (const char **pfil > warn_narrowing = 1; > > /* Unless -f{,no-}ext-numeric-literals has been used explicitly, > - for -std=c++{11,14,17} default to -fno-ext-numeric-literals. */ > + for -std=c++{11,14,17,2a} default to -fno-ext-numeric-literals. */ > if (flag_iso && !global_options_set.x_flag_ext_numeric_literals) > cpp_opts->ext_numeric_literals = 0; > } > @@ -1589,7 +1596,7 @@ set_std_cxx14 (int iso) > flag_no_gnu_keywords = iso; > flag_no_nonansi_builtin = iso; > flag_iso = iso; > - /* C++11 includes the C99 standard library. */ > + /* C++14 includes the C99 standard library. */ > flag_isoc94 = 1; > flag_isoc99 = 1; > cxx_dialect = cxx14; > @@ -1604,7 +1611,7 @@ set_std_cxx17 (int iso) > flag_no_gnu_keywords = iso; > flag_no_nonansi_builtin = iso; > flag_iso = iso; > - /* C++11 includes the C99 standard library. */ > + /* C++17 includes the C11 standard library. */ > flag_isoc94 = 1; > flag_isoc99 = 1; > flag_isoc11 = 1; > @@ -1612,6 +1619,22 @@ set_std_cxx17 (int iso) > lang_hooks.name = "GNU C++17"; > } > > +/* Set the C++ 202a draft standard (without GNU extensions if ISO). */ > +static void > +set_std_cxx2a (int iso) > +{ > + cpp_set_lang (parse_in, iso ? CLK_CXX2A: CLK_GNUCXX2A); > + flag_no_gnu_keywords = iso; > + flag_no_nonansi_builtin = iso; > + flag_iso = iso; > + /* C++17 includes the C11 standard library. */ > + flag_isoc94 = 1; > + flag_isoc99 = 1; > + flag_isoc11 = 1; > + cxx_dialect = cxx2a; > + lang_hooks.name = "GNU C++17"; /* Pretend C++17 until standardization. */ > +} > + > /* Args to -d specify what to dump. Silently ignore > unrecognized options; they may be aimed at toplev.c. */ > static void > --- gcc/c-family/c.opt.jj 2017-09-14 22:53:34.977313456 +0200 > +++ gcc/c-family/c.opt 2017-09-15 12:59:25.542053945 +0200 > @@ -1932,6 +1932,10 @@ std=c++17 > C++ ObjC++ > Conform to the ISO 2017 C++ standard. > > +std=c++2a > +C++ ObjC++ > +Conform to the ISO 2020(?) C++ draft standard (experimental and incomplete > support). > + > std=c11 > C ObjC > Conform to the ISO 2011 C standard. > @@ -1990,6 +1994,10 @@ std=gnu++17 > C++ ObjC++ > Conform to the ISO 2017 C++ standard with GNU extensions. > > +std=gnu++2a > +C++ ObjC++ > +Conform to the ISO 2020(?) C++ draft standard with GNU extensions > (experimental and incomplete support). > + > std=gnu11 > C ObjC > Conform to the ISO 2011 C standard with GNU extensions. > --- gcc/doc/cpp.texi.jj 2017-09-14 22:53:34.000000000 +0200 > +++ gcc/doc/cpp.texi 2017-09-15 14:23:32.394163061 +0200 > @@ -1877,7 +1877,10 @@ selected, the value of the macro is > @code{199711L} for the 1998 C++ standard, > @code{201103L} for the 2011 C++ standard, > @code{201402L} for the 2014 C++ standard, > -@code{201703L} for the 2017 C++ standard. > +@code{201703L} for the 2017 C++ standard, > +or an unspecified value strictly larger than @code{201703L} for the > +experimental languages enabled by @option{-std=c++2a} and > +@option{-std=gnu++2a}. > > @item __OBJC__ > This macro is defined, with value 1, when the Objective-C compiler is in > --- gcc/doc/invoke.texi.jj 2017-09-15 14:21:24.861740328 +0200 > +++ gcc/doc/invoke.texi 2017-09-15 14:22:04.607248773 +0200 > @@ -1879,6 +1879,16 @@ The name @samp{c++1z} is deprecated. > @itemx gnu++1z > GNU dialect of @option{-std=c++17}. > The name @samp{gnu++1z} is deprecated. > + > +@item c++2a > +The next revision of the ISO C++ standard, tentatively planned for > +2020. Support is highly experimental, and will almost certainly > +change in incompatible ways in future releases. > + > +@item gnu++2a > +GNU dialect of @option{-std=c++2a}. Support is highly experimental, > +and will almost certainly change in incompatible ways in future > +releases. > @end table > > @item -fgnu89-inline > --- gcc/testsuite/lib/target-supports.exp.jj 2017-09-14 22:53:35.000000000 > +0200 > +++ gcc/testsuite/lib/target-supports.exp 2017-09-15 14:34:44.232867697 > +0200 > @@ -7863,8 +7863,35 @@ proc check_effective_target_c++17_only { > } > return 0 > } > + > proc check_effective_target_c++17 { } { > - return [check_effective_target_c++17_only] > + if [check_effective_target_c++17_only] { > + return 1 > + } > + return [check_effective_target_c++2a] > +} > +proc check_effective_target_c++17_down { } { > + if ![check_effective_target_c++] { > + return 0 > + } > + return [expr ![check_effective_target_c++2a] ] > +} > + > +proc check_effective_target_c++2a_only { } { > + global cxx_default > + if ![check_effective_target_c++] { > + return 0 > + } > + if [check-flags { { } { } { -std=c++2a -std=gnu++2a } }] { > + return 1 > + } > + if { $cxx_default == "c++20" && [check-flags { { } { } { } { -std=* } }] > } { > + return 1 > + } > + return 0 > +} > +proc check_effective_target_c++2a { } { > + return [check_effective_target_c++2a_only] > } > > # Check for C++ Concepts TS support, i.e. -fconcepts flag. > --- gcc/testsuite/g++.dg/cpp2a/cplusplus.C.jj 2017-09-15 12:59:25.543053933 > +0200 > +++ gcc/testsuite/g++.dg/cpp2a/cplusplus.C 2017-09-15 12:59:25.543053933 > +0200 > @@ -0,0 +1,4 @@ > +// { dg-do compile } > +// { dg-options "-std=c++2a" } > + > +static_assert(__cplusplus > 201703L); > --- libcpp/include/cpplib.h.jj 2017-09-15 12:59:25.544053920 +0200 > +++ libcpp/include/cpplib.h 2017-09-15 13:01:03.516828002 +0200 > @@ -171,7 +171,8 @@ enum cpp_ttype > enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, > CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, > CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11, > - CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17, CLK_ASM}; > + CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17, > + CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM}; > > /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */ > struct GTY(()) cpp_string { > --- libcpp/init.c.jj 2017-09-15 12:59:25.545053908 +0200 > +++ libcpp/init.c 2017-09-15 13:00:43.267081384 +0200 > @@ -110,6 +110,8 @@ static const struct lang_flags lang_defa > /* CXX14 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 0 }, > /* GNUCXX17 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, > 0, 1 }, > /* CXX17 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 0, 1 }, > + /* GNUCXX2A */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, > 0, 1 }, > + /* CXX2A */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 0, 1 }, > /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0 } > }; > > @@ -497,7 +499,10 @@ cpp_init_builtins (cpp_reader *pfile, in > > if (CPP_OPTION (pfile, cplusplus)) > { > - if (CPP_OPTION (pfile, lang) == CLK_CXX17 > + if (CPP_OPTION (pfile, lang) == CLK_CXX2A > + || CPP_OPTION (pfile, lang) == CLK_GNUCXX2A) > + _cpp_define_builtin (pfile, "__cplusplus 201709L"); > + else if (CPP_OPTION (pfile, lang) == CLK_CXX17 > || CPP_OPTION (pfile, lang) == CLK_GNUCXX17) > _cpp_define_builtin (pfile, "__cplusplus 201703L"); > else if (CPP_OPTION (pfile, lang) == CLK_CXX14 > > > Jakub