Re: [PATCH] Add -std=c++2a

2017-09-15 Thread Pedro Alves
On 09/15/2017 01:53 PM, Jakub Jelinek wrote:
> On Mon, Aug 07, 2017 at 02:17:17PM +0100, Pedro Alves wrote:
>> I happened to skim this patch and notice a couple issues.
>> See below.
> 
> Note I've just posted updated patch based on this to gcc-patches.

Thanks ( FWIW :-) ).

>>> @@ -497,7 +499,10 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
>>>  
>>>if (CPP_OPTION (pfile, cplusplus))
>>>  {
>>> -  if (CPP_OPTION (pfile, lang) == CLK_CXX1Z
>>> +  if (CPP_OPTION (pfile, lang) == CLK_CXX2A
>>> + || CPP_OPTION (pfile, lang) == CLK_GNUCXX2A)
>>> +   _cpp_define_builtin (pfile, "__cplusplus 201707L");
>>
>> I think you wanted 202007L here.
> 
> The documentation states some unspecified value strictly greater than
> 201703L.  In the patch I've posted it is 201709L, because that is this
> month, 202007L would be just a wild guess.  People aren't supposed to
> rely on a particular value until C++2z is finalized, so just use
> (__cplusplus > 201703L) for features beyond C++17.
> 

I see, I had assumed 202007L was the intention because that's
what was in the changeLog entry, and because "2020":

Add support for C++2a.
* 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 202007L for C++2x.
^^

Thanks,
Pedro Alves



Re: [PATCH] Add -std=c++2a

2017-09-15 Thread Jakub Jelinek
On Mon, Aug 07, 2017 at 02:17:17PM +0100, Pedro Alves wrote:
> I happened to skim this patch and notice a couple issues.
> See below.

Note I've just posted updated patch based on this to gcc-patches.

> > +/* 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++1z includes the C99 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.  
> > */
> 
> Did you mean to write C++20 here?

No, that matches what we did with C++1z until the patch I've just posted.

> > --- a/libcpp/include/cpplib.h
> > +++ b/libcpp/include/cpplib.h
> > @@ -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_GNUCXX1Z, CLK_CXX1Z, CLK_ASM};
> > +CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX1Z, CLK_CXX1Z,
> > + CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};
> 
> Tabs vs spaces?

Fixed.
> 
> > @@ -497,7 +499,10 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
> >  
> >if (CPP_OPTION (pfile, cplusplus))
> >  {
> > -  if (CPP_OPTION (pfile, lang) == CLK_CXX1Z
> > +  if (CPP_OPTION (pfile, lang) == CLK_CXX2A
> > + || CPP_OPTION (pfile, lang) == CLK_GNUCXX2A)
> > +   _cpp_define_builtin (pfile, "__cplusplus 201707L");
> 
> I think you wanted 202007L here.

The documentation states some unspecified value strictly greater than
201703L.  In the patch I've posted it is 201709L, because that is this
month, 202007L would be just a wild guess.  People aren't supposed to
rely on a particular value until C++2z is finalized, so just use
(__cplusplus > 201703L) for features beyond C++17.

Jakub


Re: [PATCH] Add -std=c++2a

2017-08-07 Thread Pedro Alves
On 07/20/2017 02:33 PM, Andrew Sutton wrote:
> This adds a new C++ dialect, enabled by -std=c++2a.

Hi Andrew,

I happened to skim this patch and notice a couple issues.
See below.


> +/* 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++1z includes the C99 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.  */

Did you mean to write C++20 here?

> --- a/libcpp/include/cpplib.h
> +++ b/libcpp/include/cpplib.h
> @@ -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_GNUCXX1Z, CLK_CXX1Z, CLK_ASM};
> +  CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX1Z, CLK_CXX1Z,
> + CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};

Tabs vs spaces?

> @@ -497,7 +499,10 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
>  
>if (CPP_OPTION (pfile, cplusplus))
>  {
> -  if (CPP_OPTION (pfile, lang) == CLK_CXX1Z
> +  if (CPP_OPTION (pfile, lang) == CLK_CXX2A
> +   || CPP_OPTION (pfile, lang) == CLK_GNUCXX2A)
> + _cpp_define_builtin (pfile, "__cplusplus 201707L");

I think you wanted 202007L here.

> +  else if (CPP_OPTION (pfile, lang) == CLK_CXX1Z
> || CPP_OPTION (pfile, lang) == CLK_GNUCXX1Z)
>   _cpp_define_builtin (pfile, "__cplusplus 201703L");
>else if (CPP_OPTION (pfile, lang) == CLK_CXX14
> 

Thanks,
Pedro Alves



Re: [PATCH] Add -std=c++2a

2017-07-31 Thread Joseph Myers
On Thu, 20 Jul 2017, Andrew Sutton wrote:

> This adds a new C++ dialect, enabled by -std=c++2a.

I don't see documentation here.  I'd expect additions to invoke.texi and 
standards.texi discussing the new option.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] Add -std=c++2a

2017-07-20 Thread Markus Trippelsdorf
On 2017.07.20 at 19:04 +0200, Markus Trippelsdorf wrote:
> On 2017.07.20 at 09:33 -0400, Andrew Sutton wrote:
> > This adds a new C++ dialect, enabled by -std=c++2a.
> > 
> > libcpp/
> > Add support for C++2a.
> > * 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 201707L for C++2x.
> > 
> > gcc/c-family/
> > 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.
> > 
> > gcc/testsuite/
> > New test for -std=c++2a.
> > * g++.dg/cpp2a/cplusplus.C: New.
> 
> Perhaps you should enable -fconcepts by default?

On top of your patch:

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index eed9e72b17f0..a923c3e9eedf 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -1626,6 +1626,7 @@ set_std_cxx2a (int iso)
   flag_isoc94 = 1;
   flag_isoc99 = 1;
   flag_isoc11 = 1;
+  flag_concepts = 1;
   cxx_dialect = cxx2a;
   lang_hooks.name = "GNU C++17"; /* Pretend C++17 until standardization.  */
 }

-- 
Markus


Re: [PATCH] Add -std=c++2a

2017-07-20 Thread Andrew Sutton
For now, I think these two are incompatible. There are more features
in -fconcepts than in C++20 (so far). There are also some changes in
syntax and semantics that would be nice to diagnose. A good example
would be 'concept' as a decl-specifier (TS) vs. 'concept' as a
declaration introducer (WD).

I was going to submit a followup that emits a warning when both
-std=c++2a and -fconcepts are both enabled and then disables
-fconcepts.

Andrew Sutton


On Thu, Jul 20, 2017 at 1:04 PM, Markus Trippelsdorf
 wrote:
> On 2017.07.20 at 09:33 -0400, Andrew Sutton wrote:
>> This adds a new C++ dialect, enabled by -std=c++2a.
>>
>> libcpp/
>> Add support for C++2a.
>> * 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 201707L for C++2x.
>>
>> gcc/c-family/
>> 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.
>>
>> gcc/testsuite/
>> New test for -std=c++2a.
>> * g++.dg/cpp2a/cplusplus.C: New.
>
> Perhaps you should enable -fconcepts by default?
>
> --
> Markus


Re: [PATCH] Add -std=c++2a

2017-07-20 Thread Markus Trippelsdorf
On 2017.07.20 at 09:33 -0400, Andrew Sutton wrote:
> This adds a new C++ dialect, enabled by -std=c++2a.
> 
> libcpp/
> Add support for C++2a.
> * 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 201707L for C++2x.
> 
> gcc/c-family/
> 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.
> 
> gcc/testsuite/
> New test for -std=c++2a.
> * g++.dg/cpp2a/cplusplus.C: New.

Perhaps you should enable -fconcepts by default?

-- 
Markus


[PATCH] Add -std=c++2a

2017-07-20 Thread Andrew Sutton
This adds a new C++ dialect, enabled by -std=c++2a.

libcpp/
Add support for C++2a.
* 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 201707L for C++2x.

gcc/c-family/
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.

gcc/testsuite/
New test for -std=c++2a.
* g++.dg/cpp2a/cplusplus.C: New.


Andrew Sutton


cxx2a.patch
Description: Binary data