Re: [C++ PATCH] Feature macros are long

2019-10-30 Thread Nathan Sidwell

On 10/30/19 12:36 PM, Jakub Jelinek wrote:

On Wed, Oct 30, 2019 at 12:33:00PM -0400, Nathan Sidwell wrote:

As discussed on IRC, this adds an L suffix to C++ feature macros, as
specified by the std.  I'd forgotten that in preprocessor-land, expressions
are evaluated as longs anyway, but the user might be trying to printf these
constants, or similar, where the type suffix is significant.

Jakub, Thomas:
 cpp_define (pfile, "_OPENACC=201306");
 cpp_define (pfile, "_OPENMP=201511");
those two macros might need suffixing too, but I don't have a std handy.


"the _OPENMP macro name is defined to have the
decimal value mm where  and mm are the year and month designations
of the version of the OpenMP API that the implementation supports."
I think that doesn't imply L suffix, but can ask.


'decimal value' is a confused term.  It's a number with value, type and 
representation.  If it said the token mmm where ..., I'd understand.


nathan

--
Nathan Sidwell


Re: [C++ PATCH] Feature macros are long

2019-10-30 Thread Jakub Jelinek
On Wed, Oct 30, 2019 at 12:33:00PM -0400, Nathan Sidwell wrote:
> As discussed on IRC, this adds an L suffix to C++ feature macros, as
> specified by the std.  I'd forgotten that in preprocessor-land, expressions
> are evaluated as longs anyway, but the user might be trying to printf these
> constants, or similar, where the type suffix is significant.
> 
> Jakub, Thomas:
> cpp_define (pfile, "_OPENACC=201306");
> cpp_define (pfile, "_OPENMP=201511");
> those two macros might need suffixing too, but I don't have a std handy.

"the _OPENMP macro name is defined to have the
decimal value mm where  and mm are the year and month designations
of the version of the OpenMP API that the implementation supports."
I think that doesn't imply L suffix, but can ask.

Jakub



[C++ PATCH] Feature macros are long

2019-10-30 Thread Nathan Sidwell
As discussed on IRC, this adds an L suffix to C++ feature macros, as 
specified by the std.  I'd forgotten that in preprocessor-land, 
expressions are evaluated as longs anyway, but the user might be trying 
to printf these constants, or similar, where the type suffix is significant.


Jakub, Thomas:
cpp_define (pfile, "_OPENACC=201306");
cpp_define (pfile, "_OPENMP=201511");
those two macros might need suffixing too, but I don't have a std handy.

nathan
--
Nathan Sidwell
2019-10-30  Nathan Sidwell  

	* c-cppbuiltin.c (c_cpp_builtins): Add 'L' suffix to feature
	macros.

Index: c-family/c-cppbuiltin.c
===
--- c-family/c-cppbuiltin.c	(revision 277620)
+++ c-family/c-cppbuiltin.c	(working copy)
@@ -890,7 +890,7 @@ c_cpp_builtins (cpp_reader *pfile)
   if (flag_rtti)
 	{
 	  cpp_define (pfile, "__GXX_RTTI");
-	  cpp_define (pfile, "__cpp_rtti=199711");
+	  cpp_define (pfile, "__cpp_rtti=199711L");
 	}
 
   if (cxx_dialect >= cxx11)
@@ -899,11 +899,11 @@ c_cpp_builtins (cpp_reader *pfile)
   /* Binary literals have been allowed in g++ before C++11
 	 and were standardized for C++14.  */
   if (!pedantic || cxx_dialect > cxx11)
-	cpp_define (pfile, "__cpp_binary_literals=201304");
+	cpp_define (pfile, "__cpp_binary_literals=201304L");
 
   /* Similarly for hexadecimal floating point literals and C++17.  */
   if (!pedantic || cpp_get_options (parse_in)->extended_numbers)
-	cpp_define (pfile, "__cpp_hex_float=201603");
+	cpp_define (pfile, "__cpp_hex_float=201603L");
 
   /* Arrays of runtime bound were removed from C++14, but we still
 	 support GNU VLAs.  Let's define this macro to a low number
@@ -911,112 +911,112 @@ c_cpp_builtins (cpp_reader *pfile)
 	 complain about use of VLAs.  */
   if (c_dialect_cxx ()
 	  && (pedantic ? warn_vla == 0 : warn_vla <= 0))
-	cpp_define (pfile, "__cpp_runtime_arrays=198712");
+	cpp_define (pfile, "__cpp_runtime_arrays=198712L");
 
   if (cxx_dialect >= cxx11)
 	{
 	  /* Set feature test macros for C++11.  */
 	  if (cxx_dialect <= cxx14)
-	cpp_define (pfile, "__cpp_unicode_characters=200704");
-	  cpp_define (pfile, "__cpp_raw_strings=200710");
-	  cpp_define (pfile, "__cpp_unicode_literals=200710");
-	  cpp_define (pfile, "__cpp_user_defined_literals=200809");
-	  cpp_define (pfile, "__cpp_lambdas=200907");
+	cpp_define (pfile, "__cpp_unicode_characters=200704L");
+	  cpp_define (pfile, "__cpp_raw_strings=200710L");
+	  cpp_define (pfile, "__cpp_unicode_literals=200710L");
+	  cpp_define (pfile, "__cpp_user_defined_literals=200809L");
+	  cpp_define (pfile, "__cpp_lambdas=200907L");
 	  if (cxx_dialect == cxx11)
-	cpp_define (pfile, "__cpp_constexpr=200704");
+	cpp_define (pfile, "__cpp_constexpr=200704L");
 	  if (cxx_dialect <= cxx14)
-	cpp_define (pfile, "__cpp_range_based_for=200907");
+	cpp_define (pfile, "__cpp_range_based_for=200907L");
 	  if (cxx_dialect <= cxx14)
-	cpp_define (pfile, "__cpp_static_assert=200410");
-	  cpp_define (pfile, "__cpp_decltype=200707");
-	  cpp_define (pfile, "__cpp_attributes=200809");
-	  cpp_define (pfile, "__cpp_rvalue_reference=200610");
-	  cpp_define (pfile, "__cpp_rvalue_references=200610");
-	  cpp_define (pfile, "__cpp_variadic_templates=200704");
-	  cpp_define (pfile, "__cpp_initializer_lists=200806");
-	  cpp_define (pfile, "__cpp_delegating_constructors=200604");
-	  cpp_define (pfile, "__cpp_nsdmi=200809");
+	cpp_define (pfile, "__cpp_static_assert=200410L");
+	  cpp_define (pfile, "__cpp_decltype=200707L");
+	  cpp_define (pfile, "__cpp_attributes=200809L");
+	  cpp_define (pfile, "__cpp_rvalue_reference=200610L");
+	  cpp_define (pfile, "__cpp_rvalue_references=200610L");
+	  cpp_define (pfile, "__cpp_variadic_templates=200704L");
+	  cpp_define (pfile, "__cpp_initializer_lists=200806L");
+	  cpp_define (pfile, "__cpp_delegating_constructors=200604L");
+	  cpp_define (pfile, "__cpp_nsdmi=200809L");
 	  if (!flag_new_inheriting_ctors)
-	cpp_define (pfile, "__cpp_inheriting_constructors=200802");
+	cpp_define (pfile, "__cpp_inheriting_constructors=200802L");
 	  else
-	cpp_define (pfile, "__cpp_inheriting_constructors=201511");
-	  cpp_define (pfile, "__cpp_ref_qualifiers=200710");
-	  cpp_define (pfile, "__cpp_alias_templates=200704");
+	cpp_define (pfile, "__cpp_inheriting_constructors=201511L");
+	  cpp_define (pfile, "__cpp_ref_qualifiers=200710L");
+	  cpp_define (pfile, "__cpp_alias_templates=200704L");
 	}
   if (cxx_dialect > cxx11)
 	{
 	  /* Set feature test macros for C++14.  */
-	  cpp_define (pfile, "__cpp_return_type_deduction=201304");
-	  cpp_define (pfile, "__cpp_init_captures=201304");
-	  cpp_define (pfile, "__cpp_generic_lambdas=201304");
+	  cpp_define (pfile, "__cpp_return_type_deduction=201304L");
+	  cpp_define (pfile, "__cpp_init_captures=201304L");
+	  cpp_define (pfile, "__cpp_generic_lambdas=201304L");
 	  if (cxx_dialect <= cxx14)
-