Re: [C++11, C++14 PATCH 2/3] Support for SD-6: SG10 Feature Test Recommendations - c-family and testsuite

2014-06-02 Thread Jason Merrill

On 05/31/2014 02:30 AM, Marc Glisse wrote:

Also, I am pretty sure that gcc doesn't support the latest constexpr, we
shouldn't define those macros lightly.


That's correct.  We should leave __cpp_constexpr at 200704 for now.


I think having __has_include for all languages is fine since it is
already in the implementation defined namespace.


Agreed.  These macros should be defined if the feature is supported.

Similarly, features of later standards that we implement in earlier 
conformance modes as extensions (specifically, init-captures and binary 
literals) should have the appropriate macros defined.


Jason



Re: [C++11, C++14 PATCH 2/3] Support for SD-6: SG10 Feature Test Recommendations - c-family and testsuite

2014-06-02 Thread Ed Smith-Rowland

On 06/02/2014 10:31 AM, Jason Merrill wrote:

On 05/31/2014 02:30 AM, Marc Glisse wrote:

Also, I am pretty sure that gcc doesn't support the latest constexpr, we
shouldn't define those macros lightly.


That's correct.  We should leave __cpp_constexpr at 200704 for now.
Right...  That was a testing thing I left in by accident to make sure 
supercedance would work.  Commented out. ;-)



I think having __has_include for all languages is fine since it is
already in the implementation defined namespace.


Agreed.  These macros should be defined if the feature is supported.

I now have these for all C/C++ versions.  When I implemented these I 
thought Why the heck hasn't the preprocessor had these for 20 years...
Similarly, features of later standards that we implement in earlier 
conformance modes as extensions (specifically, init-captures and 
binary literals) should have the appropriate macros defined.

Very good idea...
I'll research these. unless someone has a little list somewhere...?


Jason






Re: [C++11, C++14 PATCH 2/3] Support for SD-6: SG10 Feature Test Recommendations - c-family and testsuite

2014-05-31 Thread Marc Glisse

On Fri, 30 May 2014, Ed Smith-Rowland wrote:


+ cpp_undef (pfile, __cpp_constexpr);
+ cpp_define (pfile, __cpp_constexpr=201304);


Could you set the other value in an else branch to avoid a def undef redef 
game?


Also, I am pretty sure that gcc doesn't support the latest constexpr, we 
shouldn't define those macros lightly.


--
Marc Glisse


[C++11, C++14 PATCH 2/3] Support for SD-6: SG10 Feature Test Recommendations - c-family and testsuite

2014-05-30 Thread Ed Smith-Rowland
This is the c-family part: Setting the language feature macos and 
defining the __has_include macro.



c-family:

2014-05-31  Ed Smith-Rowland  3dw...@verizon.net

Implement SD-6: SG10 Feature Test Recommendations
* c-cppbuiltin.c (c_cpp_builtins()): Define language feature
macros and the __has_header macro.


libstdc++:

2014-05-31  Ed Smith-Rowland  3dw...@verizon.net

Implement SD-6: SG10 Feature Test Recommendations
* g++.dg/cpp1y/feat-cxx11-neg.C: New.
* g++.dg/cpp1y/feat-cxx11.C: New.
* g++.dg/cpp1y/feat-cxx14-neg.C: New.
* g++.dg/cpp1y/feat-cxx14.C: New.
* g++.dg/cpp1y/phoobhar.h: New.
* g++.dg/cpp1y/testinc/phoobhar.h: New.
* g++.dg/cpp1y/testinc/phoobhar.h: New.
Index: c-family/c-cppbuiltin.c
===
--- c-family/c-cppbuiltin.c (revision 211078)
+++ c-family/c-cppbuiltin.c (working copy)
@@ -805,7 +805,43 @@
   if (flag_rtti)
cpp_define (pfile, __GXX_RTTI);
   if (cxx_dialect = cxx11)
-cpp_define (pfile, __GXX_EXPERIMENTAL_CXX0X__);
+   {
+  cpp_define (pfile, __GXX_EXPERIMENTAL_CXX0X__);
+ /* Set feature test macros for C++11  */
+ cpp_define (pfile, __has_include(STR)=__has_include__(STR));
+ cpp_define (pfile,
+ __has_include_next(STR)=__has_include_next__(STR));
+
+ 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_constexpr=200704);
+ 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_variadic_templates=200704);
+ cpp_define (pfile, __cpp_alias_templates=200704);
+   }
+  if (cxx_dialect  cxx11)
+   {
+ /* Set feature test macros for C++14  */
+ cpp_define (pfile, __cpp_binary_literals=201304);
+ cpp_define (pfile, __cpp_init_captures=201304);
+ cpp_define (pfile, __cpp_generic_lambdas=201304);
+ cpp_undef (pfile, __cpp_constexpr);
+ cpp_define (pfile, __cpp_constexpr=201304);
+ cpp_define (pfile, __cpp_decltype_auto=201304);
+ cpp_define (pfile, __cpp_return_type_deduction=201304);
+ cpp_define (pfile, __cpp_runtime_arrays=201304);
+ //cpp_define (pfile, __cpp_aggregate_nsdmi=201304);
+ //cpp_define (pfile, __cpp_variable_templates=201304);
+ cpp_define (pfile, __cpp_digit_separators=201309);
+ cpp_define (pfile, __cpp_attribute_deprecated=201309);
+ //cpp_define (pfile, __cpp_sized_deallocation=201309);
+   }
 }
   /* Note that we define this for C as well, so that we know if
  __attribute__((cleanup)) will interface with EH.  */
Index: testsuite/g++.dg/cpp1y/feat-cxx11-neg.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (revision 0)
+++ testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (working copy)
@@ -0,0 +1,35 @@
+// { dg-do compile { target c++11_only } }
+
+// These *are* defined in C++14 onwards.
+
+#ifndef __cpp_binary_literals
+#  error __cpp_binary_literals // { dg-error error }
+#endif
+
+#ifndef __cpp_init_captures
+#  error __cpp_init_captures // { dg-error error }
+#endif
+
+#ifndef __cpp_generic_lambdas
+#  error __cpp_generic_lambdas // { dg-error error }
+#endif
+
+#ifndef __cpp_decltype_auto
+#  error __cpp_decltype_auto // { dg-error error }
+#endif
+
+#ifndef __cpp_return_type_deduction
+#  error __cpp_return_type_deduction // { dg-error error }
+#endif
+
+#ifndef __cpp_runtime_arrays
+#  error __cpp_runtime_arrays // { dg-error error }
+#endif
+
+#ifndef __cpp_digit_separators
+#  error __cpp_digit_separators // { dg-error error }
+#endif
+
+#ifndef __cpp_attribute_deprecated
+#  error __cpp_attribute_deprecated // { dg-error error }
+#endif
Index: testsuite/g++.dg/cpp1y/feat-cxx11.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx11.C (revision 0)
+++ testsuite/g++.dg/cpp1y/feat-cxx11.C (working copy)
@@ -0,0 +1,73 @@
+// { dg-do compile { target c++11_only } }
+
+#ifndef __cpp_unicode_characters
+#  error __cpp_unicode_characters
+#elif  __cpp_unicode_characters != 200704
+#  error __cpp_unicode_characters != 200704
+#endif
+
+#ifndef __cpp_raw_strings
+#  error __cpp_raw_strings
+#elif  __cpp_raw_strings != 200710
+#  error __cpp_raw_strings != 200710
+#endif
+
+#ifndef __cpp_unicode_literals
+#  error __cpp_unicode_literals
+#elif  __cpp_unicode_literals != 200710
+#  error