]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Revert addition of constraints to make_signed/make_unsigned
authorJonathan Wakely <jwakely@redhat.com>
Mon, 10 Oct 2022 14:06:53 +0000 (15:06 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 10 Oct 2022 20:37:03 +0000 (21:37 +0100)
Constraining the primary template makes it unusable in uninstantiated
contexts.

libstdc++-v3/ChangeLog:

* include/std/type_traits (make_signed, make_unsigned): Remove
constraints on primary template.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Undo changes to expected error in C++20 mode.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/24_iterators/range_access/range_access_cpp20_neg.cc:
Likewise.
* testsuite/20_util/make_signed/requirements/uninstantiated.cc:
New test.
* testsuite/20_util/make_unsigned/requirements/uninstantiated.cc:
New test.

libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
libstdc++-v3/testsuite/20_util/make_signed/requirements/uninstantiated.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
libstdc++-v3/testsuite/20_util/make_unsigned/requirements/uninstantiated.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc

index 6108b98aa6a6ce207fcc872fcb9a576e18673903..1d7c3b04a0eac81c0cee6d6d4a7223a0d1950bdd 100644 (file)
@@ -1802,9 +1802,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Primary template.
   /// make_unsigned
   template<typename _Tp>
-#if __cpp_concepts
-    requires is_integral<_Tp>::value || __is_enum(_Tp)
-#endif
     struct make_unsigned
     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
 
@@ -1937,9 +1934,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Primary template.
   /// make_signed
   template<typename _Tp>
-#if __cpp_concepts
-    requires is_integral<_Tp>::value || __is_enum(_Tp)
-#endif
     struct make_signed
     { typedef typename __make_signed_selector<_Tp>::__type type; };
 
index 88b8ae887ef42fe9e4433c9ba491607e7c3968e9..451eeb8c92dbe2f360c09feea3c00bdcd35e69a7 100644 (file)
@@ -43,5 +43,4 @@ void test01()
   using T8 = make_signed<float>::type; // { dg-error "here" }
 }
 
-// { dg-error "invalid use of incomplete type" "" { target c++17_down } 0 }
-// { dg-error "constraint failure" "" { target c++20 } 0 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/uninstantiated.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/uninstantiated.cc
new file mode 100644 (file)
index 0000000..3facf0c
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++11 } }
+#include <type_traits>
+
+// Check that we can name invalid specializations, just don't instantiate them.
+
+using X = std::make_signed<float>;
+using Y = std::make_signed<bool>;
+using Z = std::make_signed<void>;
index 50f15e7037c4dd18d76c86b97887c0cb5b17f6f8..49d520936a3fc6a22a422440395bffc6337d4d27 100644 (file)
@@ -43,5 +43,4 @@ void test01()
   using T8 = make_unsigned<float>::type; // { dg-error "here" }
 }
 
-// { dg-error "invalid use of incomplete type" "" { target c++17_down } 0 }
-// { dg-error "constraint failure" "" { target c++20 } 0 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/uninstantiated.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/uninstantiated.cc
new file mode 100644 (file)
index 0000000..9b86096
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++11 } }
+#include <type_traits>
+
+// Check that we can name invalid specializations, just don't instantiate them.
+
+using X = std::make_unsigned<float>;
+using Y = std::make_unsigned<bool>;
+using Z = std::make_unsigned<void>;
index 26c8ae0ee1e7a98b7876cb0b64842f5d880bad50..c0825a585871248d3e9b7013024ad3dc2671f754 100644 (file)
@@ -46,5 +46,4 @@ test03()
   C c;
   std::ssize(c);  // { dg-error "no matching function" }
 }
-// { dg-error "incomplete type .*make_signed.*S" "" { target c++17_down } 0 }
-// { dg-error "constraint failure" "" { target c++20 } 0 }
+// { dg-error "incomplete type .*make_signed.*S" "" { target *-*-* } 0 }