On Wed, Jul 13, 2022 at 03:29:04PM -0400, Nathan Sidwell via Gcc-patches wrote: > Inspired by a user question. Jason, thoughts?
FWIW, this makes sense. I mean, how could I be against a patch quoting Macbeth?! > Since C++ is such a moving target, Microsoft have /std:c++latest > (AFAICT clang does not), to select the currently implemented version > of the working paper. But the use of 'std:latest' is somewhat > ambiguous -- the current std is C++20 -- that's the latest std, the > next std will more than likely but not necessarily be C++23. So this > adds: > > -std=c++current -- the current std (c++20) > -std=c++future -- the working paper (c++2b) > > also adds gnu++current and gnu++future to select the gnu-extended > variants. > > nathan > > -- > Nathan Sidwell > From 9671f4d5e7efa130280b6d50fb4e9e8492d5b587 Mon Sep 17 00:00:00 2001 > From: Nathan Sidwell <nat...@acm.org> > Date: Wed, 13 Jul 2022 12:11:40 -0700 > Subject: [PATCH] C++: add -std={c,gnu}++{current,future} > > Since C++ is such a moving target, Microsoft have /std:c++latest > (AFAICT clang does not), to select the currently implemented version > of the working paper. But the use of 'std:latest' is somewhat > ambiguous -- the current std is C++20 -- that's the latest std, the > next std will more than likely but not necessarily be C++23. So this > adds: > > -std=c++current -- the current std (c++20) > -std=c++future -- the working paper (c++2b) > > also adds gnu++current and gnu++future to select the gnu-extended > variants. > > gcc/ > * doc/invoke.texi (-std=): Document new c++ current & future > options. > gcc/c-family/ > * c.opt (-std={c,gnu}++{current,future}: New alias options. > gcc/testsuite/ > * g++.dg/gnu-current.C: New. > * g++.dg/gnu-future.C: New. > * g++.dg/std-current.C: New. > * g++.dg/std-future.C: New. > --- > gcc/c-family/c.opt | 16 ++++++++++++++++ > gcc/doc/invoke.texi | 23 +++++++++++++++++++++++ > gcc/testsuite/g++.dg/gnu-current.C | 7 +++++++ > gcc/testsuite/g++.dg/gnu-future.C | 7 +++++++ > gcc/testsuite/g++.dg/std-current.C | 11 +++++++++++ > gcc/testsuite/g++.dg/std-future.C | 8 ++++++++ > 6 files changed, 72 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/gnu-current.C > create mode 100644 gcc/testsuite/g++.dg/gnu-future.C > create mode 100644 gcc/testsuite/g++.dg/std-current.C > create mode 100644 gcc/testsuite/g++.dg/std-future.C > > diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt > index 44e1a60ce24..9292029a967 100644 > --- a/gcc/c-family/c.opt > +++ b/gcc/c-family/c.opt > @@ -2321,6 +2321,14 @@ std=c++23 > C++ ObjC++ Undocumented > Conform to the ISO 2023 C++ draft standard (experimental and incomplete > support). > > +std=c++current > +C++ ObjC++ Alias(std=c++20) Undocumented > +Conform to the current ISO C++ standard (C++20). > + > +std=c++future > +C++ ObjC++ Alias(std=c++23) Undocumented > +Conform to a future ISO C++ standard (C++2b, experimentatl and incomplete > support). Since the option says 23, why not use 23 here as well instead of 2b? And below too. > + > std=c11 > C ObjC > Conform to the ISO 2011 C standard. > @@ -2407,6 +2415,14 @@ std=gnu++23 > C++ ObjC++ Undocumented > Conform to the ISO 2023 C++ draft standard with GNU extensions (experimental > and incomplete support). > > +std=gnu++current > +C++ ObjC++ Alias(std=gnu++20) Undocumented > +Conform to the current ISO C++ standard with GNU extensions (C++20). > + > +std=gnu++future > +C++ ObjC++ Alias(std=gnu++23) Undocumented > +Conform to a future ISO C++ standard with GNU extensions (C++2b, > experimentatl and incomplete support). > + > std=gnu11 > C ObjC > Conform to the ISO 2011 C standard with GNU extensions. > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index d5ff1018372..1c0edb9df68 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -2462,6 +2462,17 @@ GNU dialect of @option{-std=c++17}. > This is the default for C++ code. > The name @samp{gnu++1z} is deprecated. > > +@item gnu++current > +@itemx gnu++current > +GNU dialect of the current C++ standard, currently @option{-std=gnu++20}. > +The C++ version selected by this option is a moving target. > + > +@item gnu++future > +@itemx gnu++future > +GNU dialect of the next C++ standard, currently @option{-std=gnu++2b}. > +The C++ version selected by this option is a moving target (as are the > +semantics of that proposed version). > + > @item c++20 > @itemx c++2a > The 2020 ISO C++ standard plus amendments. > @@ -2487,6 +2498,18 @@ change in incompatible ways in future releases. > GNU dialect of @option{-std=c++2b}. Support is highly experimental, > and will almost certainly change in incompatible ways in future > releases. > + > +@item c++current > +@itemx c++current > +The current C++ standard, currently @option{-std=gnu++20}. > +The C++ version selected by this option is a moving target. > + > +@item c++future > +@itemx c++future > +The next C++ standard, currently @option{-std=gnu++2b}. > +The C++ version selected by this option is a moving target (as are the > +semantics of that proposed version). > + > @end table > > @item -aux-info @var{filename} > diff --git a/gcc/testsuite/g++.dg/gnu-current.C > b/gcc/testsuite/g++.dg/gnu-current.C > new file mode 100644 > index 00000000000..c95c56d3ad8 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/gnu-current.C > @@ -0,0 +1,7 @@ > +// { dg-do compile } > +// { dg-options -std=gnu++current } > + > +static_assert (__cplusplus == 202002L, "time has moved on"); > +#if __STRICT_ANSI__ > +#error "__STRICT_ANSI__ surprisingly non-zero" > +#endif > diff --git a/gcc/testsuite/g++.dg/gnu-future.C > b/gcc/testsuite/g++.dg/gnu-future.C > new file mode 100644 > index 00000000000..366dcdeebc2 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/gnu-future.C > @@ -0,0 +1,7 @@ > +// { dg-do compile } > +// { dg-options -std=gnu++future } > + > +static_assert (__cplusplus > 202002L, "time has moved on"); > +#if __STRICT_ANSI__ > +#error "__STRICT_ANSI__ surprisingly non-zero" > +#endif > diff --git a/gcc/testsuite/g++.dg/std-current.C > b/gcc/testsuite/g++.dg/std-current.C > new file mode 100644 > index 00000000000..334ffd1d2c4 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/std-current.C > @@ -0,0 +1,11 @@ > +// { dg-do compile } > +// { dg-options -std=c++current } > + > +// Adust as tomorrow and tomorrow and tomorrow > +// Creeps in this petty pace from day to day > +// To the last syllable of recorded time. > + > +static_assert (__cplusplus == 202002L, "time has moved on"); > +#if !__STRICT_ANSI__ > +#error "__STRICT_ANSI__ surprisingly zero" > +#endif > diff --git a/gcc/testsuite/g++.dg/std-future.C > b/gcc/testsuite/g++.dg/std-future.C > new file mode 100644 > index 00000000000..dade97e6a71 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/std-future.C > @@ -0,0 +1,8 @@ > +// { dg-do compile } > +// { dg-options -std=c++future } > + > +static_assert (__cplusplus > 202002L, "time has moved on"); > +#if !__STRICT_ANSI__ > +#error "__STRICT_ANSI__ surprisingly zero" > +#endif > + > -- > 2.30.2 > Marek