Patchwork [v3] libstdc++/52702

login
register
mail settings
Submitter Paolo Carlini
Date April 15, 2012, 11:34 p.m.
Message ID <4F8B5AEF.6010901@oracle.com>
Download mbox | patch
Permalink /patch/152736/
State New
Headers show

Comments

Paolo Carlini - April 15, 2012, 11:34 p.m.
Hi,

tested x86_64-linux, committed to mainline.

Thanks,
Paolo.

/////////////////
2012-04-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/52702
	* include/std/type_traits (is_trivially_destructible): Add.
	(has_trivial_destructor): Remove.
	* testsuite/util/testsuite_common_types.h: Adjust.
	* testsuite/20_util/tuple/requirements/dr801.cc: Likewise.
	* testsuite/20_util/pair/requirements/dr801.cc: Likewise.
	* testsuite/20_util/is_trivially_destructible/value.cc: New.
	* testsuite/20_util/is_trivially_destructible/requirements/
	typedefs.cc: Likewise.
	* testsuite/20_util/is_trivially_destructible/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.
	* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.

Patch

Index: include/std/type_traits
===================================================================
--- include/std/type_traits	(revision 186464)
+++ include/std/type_traits	(working copy)
@@ -1147,30 +1147,45 @@ 
     : public __is_nt_move_assignable_impl<_Tp>
     { };
 
-  /// has_trivial_default_constructor
+  /// is_trivially_constructible (still unimplemented)
+  
+  /// is_trivially_default_constructible (still unimplemented)
+
+  /// is_trivially_copy_constructible (still unimplemented)
+
+  /// is_trivially_move_constructible (still unimplemented)
+
+  /// is_trivially_assignable (still unimplemented)
+
+  /// is_trivially_copy_assignable (still unimplemented)
+
+  /// is_trivially_move_assignable (still unimplemented)
+
+  /// is_trivially_destructible
   template<typename _Tp>
+    struct is_trivially_destructible
+    : public __and_<is_destructible<_Tp>, integral_constant<bool,
+			      __has_trivial_destructor(_Tp)>>::type
+    { };
+
+  /// has_trivial_default_constructor (temporary legacy)
+  template<typename _Tp>
     struct has_trivial_default_constructor
     : public integral_constant<bool, __has_trivial_constructor(_Tp)>
     { };
 
-  /// has_trivial_copy_constructor
+  /// has_trivial_copy_constructor (temporary legacy)
   template<typename _Tp>
     struct has_trivial_copy_constructor
     : public integral_constant<bool, __has_trivial_copy(_Tp)>
     { };
 
-  /// has_trivial_copy_assign
+  /// has_trivial_copy_assign (temporary legacy)
   template<typename _Tp>
     struct has_trivial_copy_assign
     : public integral_constant<bool, __has_trivial_assign(_Tp)>
     { };
 
-  /// has_trivial_destructor
-  template<typename _Tp>
-    struct has_trivial_destructor
-    : public integral_constant<bool, __has_trivial_destructor(_Tp)>
-    { };
-
   /// has_virtual_destructor
   template<typename _Tp>
     struct has_virtual_destructor
Index: testsuite/util/testsuite_common_types.h
===================================================================
--- testsuite/util/testsuite_common_types.h	(revision 186464)
+++ testsuite/util/testsuite_common_types.h	(working copy)
@@ -549,7 +549,7 @@ 
 	    typedef std::has_trivial_default_constructor<_Tp> ctor_p;
 	    static_assert(ctor_p::value, "default constructor not trivial");
 
-	    typedef std::has_trivial_destructor<_Tp> dtor_p;
+	    typedef std::is_trivially_destructible<_Tp> dtor_p;
 	    static_assert(dtor_p::value, "destructor not trivial");
 	  }
 	};
Index: testsuite/20_util/tuple/requirements/dr801.cc
===================================================================
--- testsuite/20_util/tuple/requirements/dr801.cc	(revision 186464)
+++ testsuite/20_util/tuple/requirements/dr801.cc	(working copy)
@@ -29,7 +29,7 @@ 
   // static_assert(std::is_literal_type<tuple_type>::value, "! literal");
   static_assert(std::has_trivial_copy_constructor<tuple_type>::value,
 		"! triv copy");
-  static_assert(std::has_trivial_destructor<tuple_type>::value,
+  static_assert(std::is_trivially_destructible<tuple_type>::value,
 		"! triv destructor");
   // static_assert(std::is_standard_layout<tuple_type>::value,
   //		   "! standard layout");
Index: testsuite/20_util/pair/requirements/dr801.cc
===================================================================
--- testsuite/20_util/pair/requirements/dr801.cc	(revision 186473)
+++ testsuite/20_util/pair/requirements/dr801.cc	(working copy)
@@ -1,7 +1,7 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2012 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -29,7 +29,7 @@ 
   // static_assert(std::is_literal_type<pair_type>::value, "! literal");
   static_assert(std::has_trivial_copy_constructor<pair_type>::value,
 		"! triv copy");
-  static_assert(std::has_trivial_destructor<pair_type>::value,
+  static_assert(std::is_trivially_destructible<pair_type>::value,
 		"! triv destructor");
   // static_assert(std::is_standard_layout<pair_type>::value,
   //               "! standard layout");
Index: testsuite/20_util/make_signed/requirements/typedefs_neg.cc
===================================================================
--- testsuite/20_util/make_signed/requirements/typedefs_neg.cc	(revision 186464)
+++ testsuite/20_util/make_signed/requirements/typedefs_neg.cc	(working copy)
@@ -3,7 +3,8 @@ 
 
 // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
 //
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+// Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -42,11 +43,11 @@ 
   typedef make_signed<float>::type  	test5_type;
 }
 
-// { dg-error "does not name a type" "" { target *-*-* } 33 }
-// { dg-error "required from here" "" { target *-*-* } 35 }
-// { dg-error "required from here" "" { target *-*-* } 37 }
-// { dg-error "required from here" "" { target *-*-* } 40 }
-// { dg-error "required from here" "" { target *-*-* } 42 }
+// { dg-error "does not name a type" "" { target *-*-* } 34 }
+// { dg-error "required from here" "" { target *-*-* } 36 }
+// { dg-error "required from here" "" { target *-*-* } 38 }
+// { dg-error "required from here" "" { target *-*-* } 41 }
+// { dg-error "required from here" "" { target *-*-* } 43 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1566 }
-// { dg-error "declaration of" "" { target *-*-* } 1530 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1581 }
+// { dg-error "declaration of" "" { target *-*-* } 1545 }
Index: testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
===================================================================
--- testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc	(revision 186464)
+++ testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc	(working copy)
@@ -3,7 +3,8 @@ 
 
 // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
 //
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+// Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -42,11 +43,11 @@ 
   typedef make_unsigned<float>::type  		test5_type;
 }
 
-// { dg-error "does not name a type" "" { target *-*-* } 33 }
-// { dg-error "required from here" "" { target *-*-* } 35 }
-// { dg-error "required from here" "" { target *-*-* } 37 }
-// { dg-error "required from here" "" { target *-*-* } 40 }
-// { dg-error "required from here" "" { target *-*-* } 42 }
+// { dg-error "does not name a type" "" { target *-*-* } 34 }
+// { dg-error "required from here" "" { target *-*-* } 36 }
+// { dg-error "required from here" "" { target *-*-* } 38 }
+// { dg-error "required from here" "" { target *-*-* } 41 }
+// { dg-error "required from here" "" { target *-*-* } 43 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1484 }
-// { dg-error "declaration of" "" { target *-*-* } 1448 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1499 }
+// { dg-error "declaration of" "" { target *-*-* } 1463 }
Index: testsuite/20_util/declval/requirements/1_neg.cc
===================================================================
--- testsuite/20_util/declval/requirements/1_neg.cc	(revision 186464)
+++ testsuite/20_util/declval/requirements/1_neg.cc	(working copy)
@@ -2,7 +2,7 @@ 
 // { dg-do compile }
 // 2009-11-12  Paolo Carlini  <paolo.carlini@oracle.com>
 //
-// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -19,7 +19,7 @@ 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-error "static assertion failed" "" { target *-*-* } 1777 }
+// { dg-error "static assertion failed" "" { target *-*-* } 1792 }
 
 #include <utility>
 
Index: testsuite/20_util/is_trivially_destructible/value.cc
===================================================================
--- testsuite/20_util/is_trivially_destructible/value.cc	(revision 0)
+++ testsuite/20_util/is_trivially_destructible/value.cc	(revision 0)
@@ -0,0 +1,44 @@ 
+// { dg-options "-std=gnu++11" }
+//
+// 2012-04-15  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+  using std::is_trivially_destructible;
+  using namespace __gnu_test;
+
+  VERIFY( (test_category<is_trivially_destructible, int>(true)) );
+  VERIFY( (test_category<is_trivially_destructible, TType>(true)) );
+  VERIFY( (test_category<is_trivially_destructible, PODType>(true)) );
+
+  VERIFY( (test_category<is_trivially_destructible, NType>(false)) );
+  VERIFY( (test_category<is_trivially_destructible, SLType>(false)) );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
Index: testsuite/20_util/is_trivially_destructible/requirements/typedefs.cc
===================================================================
--- testsuite/20_util/is_trivially_destructible/requirements/typedefs.cc	(revision 0)
+++ testsuite/20_util/is_trivially_destructible/requirements/typedefs.cc	(revision 0)
@@ -0,0 +1,37 @@ 
+// { dg-options "-std=gnu++11" }
+//
+// 2012-04-15  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+  // Check for required typedefs
+  typedef std::is_trivially_destructible<int> test_type;
+  typedef test_type::value_type               value_type;
+  typedef test_type::type                     type;
+  typedef test_type::type::value_type         type_value_type;
+  typedef test_type::type::type               type_type;
+}
Index: testsuite/20_util/is_trivially_destructible/requirements/explicit_instantiation.cc
===================================================================
--- testsuite/20_util/is_trivially_destructible/requirements/explicit_instantiation.cc	(revision 0)
+++ testsuite/20_util/is_trivially_destructible/requirements/explicit_instantiation.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+//
+// 2012-04-15  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+  typedef short test_type;
+  template struct is_trivially_destructible<test_type>;
+}