public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed 10/8] libstdc++: Fixes for feature test macros (PR 91480)
Date: Tue, 28 Apr 2020 23:52:27 +0100	[thread overview]
Message-ID: <20200428225227.GO71320@redhat.com> (raw)
In-Reply-To: <cover.1587592482.git.jwakely@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]

Remove the non-standard __cpp_lib_allocator_is_always_equal macro and
add the missing macros for P1032R1.

         PR libstdc++/91480
         * include/bits/allocator.h (__cpp_lib_allocator_is_always_equal):
         Remove non-standard macro.
         * include/bits/stl_iterator.h (__cpp_lib_constexpr_iterator): Define
         to indicate P1032R1 support.
         * include/bits/stl_pair.h (__cpp_lib_constexpr_utility): Likewise.
         * include/std/string_view (__cpp_lib_constexpr_string_view): Likewise.
         * include/std/tuple (__cpp_lib_constexpr_tuple): Likewise.
         * include/std/version (__cpp_lib_allocator_is_always_equal): Remove.
         (__cpp_lib_constexpr_iterator, __cpp_lib_constexpr_string_view)
         (__cpp_lib_constexpr_tuple, __cpp_lib_constexpr_utility): Define.
         * testsuite/20_util/function_objects/constexpr_searcher.cc: Check
         feature test macro.
         * testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: Likewise.
         * testsuite/21_strings/basic_string_view/operations/copy/char/
         constexpr.cc: Likewise.
         * testsuite/24_iterators/insert_iterator/constexpr.cc: Likewise.

Tested powerpc64le-linux, committed to master.

I think with Iain's recent addition of __cpp_lib_coroutine and this,
all our feature test macros are present and correct (except for some
still being defined as int values rather than long).

Thanks to Alisdair Meredith for checking them and bringing the four
missing __cpp_lib_constexpr_xxx ones to my attention.




[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 8178 bytes --]

commit d0330a03606d06dc4084e9c8734a549d22676463
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Apr 28 23:31:04 2020 +0100

    libstdc++: Fixes for feature test macros (PR 91480)
    
    Remove the non-standard __cpp_lib_allocator_is_always_equal macro and
    add the missing macros for P1032R1.
    
            PR libstdc++/91480
            * include/bits/allocator.h (__cpp_lib_allocator_is_always_equal):
            Remove non-standard macro.
            * include/bits/stl_iterator.h (__cpp_lib_constexpr_iterator): Define
            to indicate P1032R1 support.
            * include/bits/stl_pair.h (__cpp_lib_constexpr_utility): Likewise.
            * include/std/string_view (__cpp_lib_constexpr_string_view): Likewise.
            * include/std/tuple (__cpp_lib_constexpr_tuple): Likewise.
            * include/std/version (__cpp_lib_allocator_is_always_equal): Remove.
            (__cpp_lib_constexpr_iterator, __cpp_lib_constexpr_string_view)
            (__cpp_lib_constexpr_tuple, __cpp_lib_constexpr_utility): Define.
            * testsuite/20_util/function_objects/constexpr_searcher.cc: Check
            feature test macro.
            * testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: Likewise.
            * testsuite/21_strings/basic_string_view/operations/copy/char/
            constexpr.cc: Likewise.
            * testsuite/24_iterators/insert_iterator/constexpr.cc: Likewise.

diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h
index ee564791dfa..dcca769938c 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -50,9 +50,6 @@
 #endif
 
 #define __cpp_lib_incomplete_container_elements 201505
-#if __cplusplus >= 201103L
-# define __cpp_lib_allocator_is_always_equal 201411
-#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index cc0b3e0a766..fdb1121f823 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -71,6 +71,7 @@
 
 #if __cplusplus > 201703L
 # define __cpp_lib_array_constexpr 201811L
+# define __cpp_lib_constexpr_iterator 201811L
 #elif __cplusplus == 201703L
 # define __cpp_lib_array_constexpr 201803L
 #endif
diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
index 505bcc32e67..491c599076e 100644
--- a/libstdc++-v3/include/bits/stl_pair.h
+++ b/libstdc++-v3/include/bits/stl_pair.h
@@ -63,6 +63,7 @@
 #endif
 #if __cplusplus > 201703L
 # include <compare>
+# define __cpp_lib_constexpr_utility 201811L
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index 289d4743548..7c7c1b3b5dd 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -48,7 +48,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-#define __cpp_lib_string_view 201803
+# define __cpp_lib_string_view 201803L
+#if __cplusplus > 201703L
+# define __cpp_lib_constexpr_string_view 201811L
+#endif
 
   // Helper for basic_string and basic_string_view members.
   constexpr size_t
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 808947781ae..db4872d3a52 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -41,6 +41,7 @@
 #include <bits/invoke.h>
 #if __cplusplus > 201703L
 # include <compare>
+# define __cpp_lib_constexpr_tuple 201811L
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index fa505f25e98..c3a5bd26e63 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -50,7 +50,6 @@
 #define __cpp_lib_result_of_sfinae 201210
 
 #if _GLIBCXX_HOSTED
-# define __cpp_lib_allocator_is_always_equal 201411
 # define __cpp_lib_allocator_traits_is_always_equal 201411
 # define __cpp_lib_shared_ptr_arrays 201611L
 #endif
@@ -157,7 +156,7 @@
 # define __cpp_lib_shared_mutex 201505
 #endif
 #define __cpp_lib_shared_ptr_weak_type 201606
-#define __cpp_lib_string_view 201803
+#define __cpp_lib_string_view 201803L
 // #define __cpp_lib_to_chars 201611L
 #define __cpp_lib_unordered_map_try_emplace 201411
 #define __cpp_lib_variant 201606L
@@ -201,8 +200,12 @@
 #define __cpp_lib_constexpr_complex 201711L
 #define __cpp_lib_constexpr_dynamic_alloc 201907L
 #define __cpp_lib_constexpr_functional 201907L
+# define __cpp_lib_constexpr_iterator 201811L
 #define __cpp_lib_constexpr_memory 201811L
 #define __cpp_lib_constexpr_numeric 201911L
+#define __cpp_lib_constexpr_string_view 201811L
+#define __cpp_lib_constexpr_tuple 201811L
+#define __cpp_lib_constexpr_utility 201811L
 #define __cpp_lib_erase_if 202002L
 #define __cpp_lib_interpolate 201902L
 #ifdef _GLIBCXX_HAS_GTHREADS
diff --git a/libstdc++-v3/testsuite/20_util/function_objects/constexpr_searcher.cc b/libstdc++-v3/testsuite/20_util/function_objects/constexpr_searcher.cc
index 642d0a388fb..f9ecbb365a4 100644
--- a/libstdc++-v3/testsuite/20_util/function_objects/constexpr_searcher.cc
+++ b/libstdc++-v3/testsuite/20_util/function_objects/constexpr_searcher.cc
@@ -19,6 +19,13 @@
 // { dg-do compile { target c++2a } }
 
 #include <functional>
+
+#ifndef __cpp_lib_constexpr_functional
+# error "Feature test macro for constexpr searcher is missing in <functional>"
+#elif __cpp_lib_constexpr_functional < 201811L
+# error "Feature test macro for constexpr searcher has wrong value in <functional>"
+#endif
+
 #include <string_view>
 
 const std::string_view
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc
index e8423b48cdb..8821932ca97 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc
@@ -18,9 +18,16 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-#include <memory>
 #include <tuple>
 
+#ifndef __cpp_lib_constexpr_tuple
+# error "Feature test macro for constexpr allocator constructors is missing in <tuple>"
+#elif __cpp_lib_constexpr_tuple < 201811L
+# error "Feature test macro for constexpr allocator constructors has wrong value in <tuple>"
+#endif
+
+#include <memory>
+
 const std::allocator<int> alloc{};
 
 constexpr bool
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc
index 86a78108696..64a0766281d 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc
@@ -20,6 +20,12 @@
 
 #include <string_view>
 
+#ifndef __cpp_lib_constexpr_string_view
+# error "Feature test macro for constexpr copy is missing in <string_view>"
+#elif __cpp_lib_constexpr_iterator < 201811L
+# error "Feature test macro for constexpr copy has wrong value in <string_view>"
+#endif
+
 constexpr bool
 test01()
 {
diff --git a/libstdc++-v3/testsuite/24_iterators/insert_iterator/constexpr.cc b/libstdc++-v3/testsuite/24_iterators/insert_iterator/constexpr.cc
index b4fc1b5e4e7..b061bc96848 100644
--- a/libstdc++-v3/testsuite/24_iterators/insert_iterator/constexpr.cc
+++ b/libstdc++-v3/testsuite/24_iterators/insert_iterator/constexpr.cc
@@ -20,6 +20,12 @@
 
 #include <iterator>
 
+#ifndef __cpp_lib_constexpr_iterator
+# error "Feature test macro for constexpr insert iterators is missing in <iterator>"
+#elif __cpp_lib_constexpr_iterator < 201811L
+# error "Feature test macro for constexpr insert iterators has wrong value in <iterator>"
+#endif
+
 struct container
 {
   using value_type = int;

      parent reply	other threads:[~2020-04-28 22:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22 21:57 [committed 0/8] libstdc++: Add/update/fix feature test macros Jonathan Wakely
2020-04-22 21:58 ` [committed 1/8] libstdc++: Update value of __cpp_lib_jthread macro Jonathan Wakely
2020-04-22 21:58 ` [committed 2/8] libstdc++: Remove non-standard feature test macros Jonathan Wakely
2020-04-22 21:58 ` [committed 3/8] libstdc++: Add missing " Jonathan Wakely
2020-04-22 21:58 ` [committed 4/8] libstdc++: Rename __cpp_lib_constexpr_invoke macro Jonathan Wakely
2020-04-22 21:59 ` [committed 5/8] libstdc++: Update __cpp_lib_concepts value Jonathan Wakely
2020-04-22 21:59 ` [committed 6/8] libstdc++: Do not define __cpp_lib_constexpr_algorithms in <utility> Jonathan Wakely
2020-04-22 21:59 ` [committed 7/8] libstdc++: Update (and revert) value of __cpp_lib_array_constexpr Jonathan Wakely
2020-04-23 20:44   ` Jonathan Wakely
2020-04-22 21:59 ` [committed 8/8] libstdc++: Define __cpp_lib_execution feature test macro Jonathan Wakely
2020-04-23 20:41 ` [committed 9/8] libstdc++: Define __cpp_lib_three_way_comparison for freestanding Jonathan Wakely
2020-04-23 20:46 ` [committed 0/8] libstdc++: Add/update/fix feature test macros Jonathan Wakely
2020-04-28 22:52 ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200428225227.GO71320@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).