Patchwork [v3] std::common_type testsuite tweaks

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 11, 2012, 12:35 p.m.
Message ID <5076BD10.30702@oracle.com>
Download mbox | patch
Permalink /patch/190891/
State New
Headers show

Comments

Paolo Carlini - Oct. 11, 2012, 12:35 p.m.
Hi

contributed by Daniel. Tested again and committed.

Paolo.

///////////////////////
2012-10-11  Daniel Krugler  <daniel.kruegler@googlemail.com>

	* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
	Update / extend.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
	Likewise.
	* testsuite/20_util/duration/requirements/sfinae_friendly_1.cc:
	Likewise.

Patch

 .../common_type/requirements/sfinae_friendly_1.cc  |   62 ++++++++++++--------
 .../common_type/requirements/sfinae_friendly_2.cc  |    6 +-
 .../duration/requirements/sfinae_friendly_1.cc     |    9 ++-
 3 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc
index c23521f..f73c6cc 100644
--- a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc
+++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc
@@ -163,20 +163,23 @@  namespace std {
   };
 }
 
-static_assert(is_type<std::common_type<int, int>, int>(), "");
-static_assert(is_type<std::common_type<ScEn, ScEn>, ScEn>(), "");
-static_assert(is_type<std::common_type<UnscEn, UnscEn>, UnscEn>(), "");
-static_assert(is_type<std::common_type<int, int>, int>(), "");
+#ifdef HAS_53000_FIXED
+static_assert(is_type<std::common_type<int, int>, int&&>(), "");
+static_assert(is_type<std::common_type<ScEn, ScEn>, ScEn&&>(), "");
+static_assert(is_type<std::common_type<UnscEn, UnscEn>, UnscEn&&>(), "");
+#endif
 static_assert(is_type<std::common_type<UnscEn, int>, int>(), "");
-static_assert(is_type<std::common_type<int, int, int>, int>(), "");
-static_assert(is_type<std::common_type<int, int, int, int>, int>(), "");
-static_assert(is_type<std::common_type<int, int, int, int, int>, int>(), "");
-static_assert(is_type<std::common_type<S, S>, S>(), "");
-static_assert(is_type<std::common_type<const S, const S>, const S>(), "");
+#ifdef HAS_53000_FIXED
+static_assert(is_type<std::common_type<int, int, int>, int&&>(), "");
+static_assert(is_type<std::common_type<int, int, int, int>, int&&>(), "");
+static_assert(is_type<std::common_type<int, int, int, int, int>, int&&>(), "");
+static_assert(is_type<std::common_type<S, S>, S&&>(), "");
+static_assert(is_type<std::common_type<const S, const S>, const S&&>(), "");
 static_assert(is_type<std::common_type<std::initializer_list<int>,
-	      std::initializer_list<int>>, std::initializer_list<int>>(), "");
-static_assert(is_type<std::common_type<B, D>, B>(), "");
-static_assert(is_type<std::common_type<D, B>, B>(), "");
+	      std::initializer_list<int>>, std::initializer_list<int>&&>(), "");
+static_assert(is_type<std::common_type<B, D>, B&&>(), "");
+static_assert(is_type<std::common_type<D, B>, B&&>(), "");
+#endif
 static_assert(is_type<std::common_type<F1, F2>, void*>(), "");
 static_assert(is_type<std::common_type<F2, F1>, void*>(), "");
 static_assert(is_type<std::common_type<G1, G2>, const volatile void*>(), "");
@@ -189,10 +192,15 @@  static_assert(is_type<std::common_type<void, void>, void>(), "");
 static_assert(is_type<std::common_type<const void, const void>, void>(), "");
 static_assert(is_type<std::common_type<int&, int&&>, int>(), "");
 static_assert(is_type<std::common_type<int&, int&>, int&>(), "");
-static_assert(is_type<std::common_type<int&&, int&&>, int>(), "");
+#ifdef HAS_53000_FIXED
+static_assert(is_type<std::common_type<int&&, int&&>, int&&>(), "");
+static_assert(is_type<std::common_type<int&&, const int&&>, const int&&>(), "");
+#endif
 static_assert(is_type<std::common_type<U&, const U&&>, const U>(), "");
 static_assert(is_type<std::common_type<U&, U&>, U&>(), "");
-static_assert(is_type<std::common_type<U&&, U&&>, U>(), "");
+#ifdef HAS_53000_FIXED
+static_assert(is_type<std::common_type<U&&, U&&>, U&&>(), "");
+#endif
 static_assert(is_type<std::common_type<int B::*, int D::*>, int D::*>(), "");
 static_assert(is_type<std::common_type<int D::*, int B::*>, int D::*>(), "");
 static_assert(is_type<std::common_type<const int B::*, volatile int D::*>,
@@ -201,7 +209,9 @@  static_assert(is_type<std::common_type<int (B::*)(), int (D::*)()>,
 	      int (D::*)()>(), "");
 static_assert(is_type<std::common_type<int (B::*)() const, int (D::*)() const>,
 	      int (D::*)() const>(), "");
-static_assert(is_type<std::common_type<int[3], int[3]>, int*>(), "");
+#ifdef HAS_53000_FIXED
+static_assert(is_type<std::common_type<int[3], int[3]>, int(&&)[3]>(), "");
+#endif
 static_assert(is_type<std::common_type<int[1], const int[3]>,
 	      const int*>(), "");
 static_assert(is_type<std::common_type<void(), void()>, void(&)()>(), "");
@@ -213,14 +223,18 @@  static_assert(is_type<std::common_type<void(&&)(), void(&)()>,
 static_assert(is_type<std::common_type<void(&&)(), void(&&)()>,
 	      void(&)()>(), "");
 static_assert(is_type<std::common_type<ImplicitTo<int>, int>, int>(), "");
+#ifdef HAS_53000_FIXED
 static_assert(is_type<std::common_type<ImplicitTo<int>, ImplicitTo<int>>,
-	      ImplicitTo<int>>(), "");
+	      ImplicitTo<int>&&>(), "");
+#endif
 static_assert(is_type<std::common_type<ImplicitTo<int>, int,
 	      ImplicitTo<int>>, int>(), "");
+#ifdef HAS_53000_FIXED
 static_assert(is_type<std::common_type<ExplicitTo<int>, ExplicitTo<int>>,
-	      ExplicitTo<int>>(), "");
+	      ExplicitTo<int>&&>(), "");
 static_assert(is_type<std::common_type<decltype(lmd1), decltype(lmd1)>,
-	      decltype(lmd1)>(), "");
+	      decltype(lmd1)&&>(), "");
+#endif
 static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd1)&>,
 	      decltype(lmd1)&>(), "");
 static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd2)&>,
@@ -248,12 +262,12 @@  static_assert(is_type<std::common_type<UConv1&, UConv2&>, Abstract*>(), "");
 
 #ifdef HAS_53000_FIXED
 static_assert(is_type<std::common_type<Abstract&&, Abstract&&>,
-	      Abstract>(), "");
+	      Abstract&&>(), "");
 static_assert(is_type<std::common_type<const Abstract&&,
-				       volatile Abstract&&>, Abstract>(), "");
-static_assert(is_type<std::common_type<Ukn&&, Ukn&&>, Ukn>(), "");
+				       volatile Abstract&&>, const volatile Abstract&&>(), "");
+static_assert(is_type<std::common_type<Ukn&&, Ukn&&>, Ukn&&>(), "");
 static_assert(is_type<std::common_type<const Ukn&&, volatile Ukn&&>,
-	      Ukn>(), "");
+	      const volatile Ukn&&>(), "");
 #endif
 
 static_assert(is_type<std::common_type<X1, X2>, RX12>(), "");
@@ -323,8 +337,10 @@  void test(int i)
   auto local_lmd1 = [=](int, double) { return i + i; };
   auto local_lmd2 = [=](int, double) { return i - i; };
 
+#ifdef HAS_53000_FIXED
   static_assert(is_type<std::common_type<decltype(local_lmd1),
-		        decltype(local_lmd1)>, decltype(local_lmd1)>(), "");
+		        decltype(local_lmd1)>, decltype(local_lmd1)&&>(), "");
+#endif
   static_assert(is_type<std::common_type<decltype(local_lmd1)&,
 		        decltype(local_lmd1)>, decltype(local_lmd1)>(), "");
   static_assert(is_type<std::common_type<decltype(local_lmd1)&,
diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc
index e4d4fa0..2f66791 100644
--- a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc
+++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc
@@ -24,10 +24,12 @@ 
 
 template<typename... Args>
 constexpr
-std::array<typename std::common_type<Args...>::type, sizeof...(Args)>
+std::array<typename std::decay<typename std::common_type<Args...>::type>::type, 
+  sizeof...(Args)>
 make_array(Args&&... args)  // { dg-error "invalid use" }
 {
-  typedef typename std::common_type<Args...>::type CT;
+  typedef typename std::decay<typename std::common_type<Args...>::type>::type 
+    CT;
   return std::array<CT, sizeof...(Args)>{static_cast<CT>
       (std::forward<Args>(args))...};
 }
diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc
index 48b0197..cf53a21 100644
--- a/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc
+++ b/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc
@@ -21,6 +21,9 @@ 
 #include <type_traits>
 #include <chrono>
 
+//TODO: Uncomment this once gcc bug 53000 has been resolved:
+//#define HAS_53000_FIXED
+
 // Helper types:
 struct has_type_impl
 {
@@ -52,8 +55,10 @@  typedef std::chrono::duration<int, std::nano> din;
 typedef std::chrono::duration<double, std::nano> ddn;
 typedef std::chrono::duration<int, std::milli> dim;
 
-static_assert(is_type<std::common_type<din, din>, din>(), "");
-static_assert(is_type<std::common_type<din, din, din>, din>(), "");
+#ifdef HAS_53000_FIXED
+static_assert(is_type<std::common_type<din, din>, din&&>(), "");
+static_assert(is_type<std::common_type<din, din, din>, din&&>(), "");
+#endif
 
 static_assert(is_type<std::common_type<din, ddn>, ddn>(), "");
 static_assert(is_type<std::common_type<din, din, ddn>, ddn>(), "");