Hi,

submitter noticed that we have the extended static_assert but the value of the feature macro is still unconditionally 200410, whereas, eg, http://wg21.link/n4440#recs.cpp17 , has 201411.

Submitter proposes to unconditionally, thus in c++11 and c++14 modes too, bump the value, but thinking more about the issue, I guess we want that only in c++1z, the only mode which doesn't trigger a pedwarn for those extended features, consistently, with eg, __cpp_init_captures which is defined only in c++14 and and c++1z but only triggers a pedwarn in c++11. Thus a slightly larger patch.

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////
c-family/
2015-08-18  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/67160
        * c-cppbuiltin.c (c_cpp_builtins): Fix __cpp_static_assert value
        in c++1z mode.

testsuite/
2015-08-18  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/67160
        * g++.dg/cpp1z/feat-cxx1z.C: New.
Index: c-family/c-cppbuiltin.c
===================================================================
--- c-family/c-cppbuiltin.c     (revision 226966)
+++ c-family/c-cppbuiltin.c     (working copy)
@@ -832,7 +832,7 @@ c_cpp_builtins (cpp_reader *pfile)
 
       if (cxx_dialect >= cxx11)
        {
-         /* Set feature test macros for C++11  */
+         /* Set feature test macros for C++11.  */
          cpp_define (pfile, "__cpp_unicode_characters=200704");
          cpp_define (pfile, "__cpp_raw_strings=200710");
          cpp_define (pfile, "__cpp_unicode_literals=200710");
@@ -841,7 +841,8 @@ c_cpp_builtins (cpp_reader *pfile)
          if (cxx_dialect == cxx11)
            cpp_define (pfile, "__cpp_constexpr=200704");
          cpp_define (pfile, "__cpp_range_based_for=200907");
-         cpp_define (pfile, "__cpp_static_assert=200410");
+         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");
@@ -855,7 +856,7 @@ c_cpp_builtins (cpp_reader *pfile)
        }
       if (cxx_dialect > cxx11)
        {
-         /* Set feature test macros for C++14  */
+         /* 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");
@@ -865,6 +866,11 @@ c_cpp_builtins (cpp_reader *pfile)
          cpp_define (pfile, "__cpp_variable_templates=201304");
          cpp_define (pfile, "__cpp_digit_separators=201309");
        }
+      if (cxx_dialect > cxx14)
+       {
+         /* Set feature test macros for C++1z.  */
+         cpp_define (pfile, "__cpp_static_assert=201411");
+       }
       if (flag_concepts)
        /* Use a value smaller than the 201507 specified in
           the TS, since we don't yet support extended auto.  */
Index: testsuite/g++.dg/cpp1z/feat-cxx1z.C
===================================================================
--- testsuite/g++.dg/cpp1z/feat-cxx1z.C (revision 0)
+++ testsuite/g++.dg/cpp1z/feat-cxx1z.C (working copy)
@@ -0,0 +1,7 @@
+// { dg-do compile { target c++1z } }
+
+#ifndef __cpp_static_assert
+#  error "__cpp_static_assert"
+#elif __cpp_static_assert != 201411
+#  error "__cpp_static_assert != 201411"
+#endif

Reply via email to