This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]