Re: [PATCH] PR libstdc++/60132, implement the remaining C++11 is_trivially_* traits

2014-10-09 Thread Ville Voutilainen
On 9 October 2014 01:45, Jonathan Wakely jwak...@redhat.com wrote:
 Some of the tests have copyright dates of 2012-2014 - I think they
 should be just 2014, even if you copied existing files.

Some of them also had 010 as the month. :)


 Please break the ChangeLog entries to fit in 80 columns, e.g.

 * testsuite/20_util/is_trivially_assignable/requirements/
explicit_instantiation.cc: New.


 Other than those minor points this is OK for trunk, thanks very much!

Ok, another try (I don't have write-after-approval, so please commit the patch
once you think it's ok):

2014-10-09  Ville Voutilainen  ville.voutilai...@gmail.com

PR libstdc++/60132
* include/std/type_traits (is_trivially_copyable,
is_trivially_constructible, is_trivially_default_constructible,
is_trivially_copy_constructible, is_trivially_move_constructible,
is_trivially_assignable, is_trivially_copy_assignable,
is_trivially_move_assignable): New.
* testsuite/20_util/is_trivially_assignable/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_assignable/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_assignable/
value.cc: New.
* testsuite/20_util/is_trivially_constructible/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_constructible/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_constructible/value.cc: New.
* testsuite/20_util/is_trivially_copyable/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_copyable/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_copyable/
value.cc: New.
* testsuite/20_util/is_trivially_copy_assignable/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_copy_assignable/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_copy_assignable/value.cc: New.
* testsuite/20_util/is_trivially_copy_constructible/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_copy_constructible/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_copy_constructible/value.cc: New.
* testsuite/20_util/is_trivially_default_constructible/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_default_constructible/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_default_constructible/value.cc: New.
* testsuite/20_util/is_trivially_move_assignable/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_move_assignable/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_move_assignable/value.cc: New.
* testsuite/20_util/is_trivially_move_constructible/requirements/
typedefs.cc: New.
* testsuite/20_util/is_trivially_move_constructible/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_trivially_move_constructible/value.cc: New.
diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index 6690044..d776efe 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -606,7 +606,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 : public integral_constantbool, __is_trivial(_Tp)
 { };
 
-  // is_trivially_copyable (still unimplemented)
+  // is_trivially_copyable
+  templatetypename _Tp
+struct is_trivially_copyable
+: public integral_constantbool, __is_trivially_copyable(_Tp)
+{ };
 
   /// is_standard_layout
   templatetypename _Tp
@@ -1282,19 +1286,58 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 : public __is_nt_move_assignable_impl_Tp
 { };
 
-  /// is_trivially_constructible (still unimplemented)
+  /// is_trivially_constructible
+  templatetypename _Tp, typename... _Args
+struct is_trivially_constructible
+: public __and_is_constructible_Tp, _Args..., integral_constantbool,
+   __is_trivially_constructible(_Tp, _Args...)::type
+{ };
   
-  /// is_trivially_default_constructible (still unimplemented)
-
-  /// is_trivially_copy_constructible (still unimplemented)
+  /// is_trivially_default_constructible
+  templatetypename _Tp
+struct is_trivially_default_constructible
+: public is_trivially_constructible_Tp::type
+{ };
 
-  /// is_trivially_move_constructible (still unimplemented)
+  /// is_trivially_copy_constructible
+  templatetypename _Tp
+struct is_trivially_copy_constructible
+: public __and_is_copy_constructible_Tp, 
+   integral_constantbool,
+   __is_trivially_constructible(_Tp, const _Tp)::type
+{ };
+  
+  /// is_trivially_move_constructible
+  templatetypename _Tp
+struct is_trivially_move_constructible
+: public __and_is_move_constructible_Tp, 
+   integral_constantbool,
+   __is_trivially_constructible(_Tp, 

Re: [PATCH] PR libstdc++/60132, implement the remaining C++11 is_trivially_* traits

2014-10-09 Thread Paolo Carlini

Hi,

On 10/09/2014 08:10 AM, Ville Voutilainen wrote:
Ok, another try (I don't have write-after-approval, so please commit 
the patch once you think it's ok):
Thanks Ville from me too. I'm taking care of the commit with a few very 
minor tweaks:
1- In new library testcases we are consistently using -std=gnu++11 and 
-std=gnu++14 (because the C++98 default is -std=gnu++98)

2- Uniform the dates to 2014-10-09.
3- Adjust the dg-error line numbers of 3 *_neg.cc testcases.

Thanks again,
Paolo.


2014-10-09  Ville Voutilainen  ville.voutilai...@gmail.com

PR libstdc++/60132
* include/std/type_traits (is_trivially_copyable,
is_trivially_constructible, is_trivially_default_constructible,
is_trivially_copy_constructible, is_trivially_move_constructible,
is_trivially_assignable, is_trivially_copy_assignable,
is_trivially_move_assignable): New.
* testsuite/20_util/is_trivially_assignable/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_assignable/value.cc: Likewise.
* testsuite/20_util/is_trivially_constructible/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_constructible/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_copyable/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_copyable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_copyable/value.cc: Likewise.
* testsuite/20_util/is_trivially_copy_assignable/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_copy_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_copy_assignable/value.cc: Likewise.
* testsuite/20_util/is_trivially_copy_constructible/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_copy_constructible/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_copy_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_default_constructible/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_default_constructible/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_default_constructible/
value.cc: Likewise.
* testsuite/20_util/is_trivially_move_assignable/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_move_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_move_assignable/value.cc: Likewise.
* testsuite/20_util/is_trivially_move_constructible/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_trivially_move_constructible/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_trivially_move_constructible/value.cc:
Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
line number.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
Index: include/std/type_traits
===
--- include/std/type_traits (revision 216027)
+++ include/std/type_traits (working copy)
@@ -606,7 +606,11 @@
 : public integral_constantbool, __is_trivial(_Tp)
 { };
 
-  // is_trivially_copyable (still unimplemented)
+  // is_trivially_copyable
+  templatetypename _Tp
+struct is_trivially_copyable
+: public integral_constantbool, __is_trivially_copyable(_Tp)
+{ };
 
   /// is_standard_layout
   templatetypename _Tp
@@ -1282,20 +1286,59 @@
 : public __is_nt_move_assignable_impl_Tp
 { };
 
-  /// is_trivially_constructible (still unimplemented)
+  /// is_trivially_constructible
+  templatetypename _Tp, typename... _Args
+struct is_trivially_constructible
+: public __and_is_constructible_Tp, _Args..., integral_constantbool,
+   __is_trivially_constructible(_Tp, _Args...)::type
+{ };
   
-  /// is_trivially_default_constructible (still unimplemented)
+  /// is_trivially_default_constructible
+  templatetypename _Tp
+struct is_trivially_default_constructible
+: public is_trivially_constructible_Tp::type
+{ };
 
-  /// is_trivially_copy_constructible (still unimplemented)
+  /// is_trivially_copy_constructible
+  templatetypename _Tp
+struct is_trivially_copy_constructible
+: public __and_is_copy_constructible_Tp, 
+   

Re: [PATCH] PR libstdc++/60132, implement the remaining C++11 is_trivially_* traits

2014-10-09 Thread Jonathan Wakely

Now that we have is_trivially_copyable ...

Update the docs and fix a TODO in atomic.

I asked Doug Gregor recently about the __is_location_invariant trait
that he used in our std::tr1::function and std::function 
implementations and he confirmed that in C++11

std::is_trivially_copyable is a better test.

Ville pointed out on IRC that we might also be able to use it in
bits/stl_algobase.h instead of __is_trivial but I haven't
investigated that properly.

Tested x86_64-linux, committed to trunk.
commit 27ae8432c1af48d9fbc15754bf93285dcfbfdbc3
Author: Jonathan Wakely jwak...@redhat.com
Date:   Thu Oct 9 18:22:23 2014 +0100

* doc/xml/manual/status_cxx2011.xml: Update.
* doc/html/manual/status.html: Regenerate.

diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml 
b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
index 108de36..c4b4457 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
@@ -811,16 +811,10 @@ particular release.
   entry/
 /row
 row
-  ?dbhtml bgcolor=#B0B0B0 ?
   entry20.9.4.3/entry
   entryType properties/entry
-  entryPartial/entry
-  entryMissing is_trivially_copyable,
-  is_trivially_constructible, is_trivially_default_constructible,
-  is_trivially_copy_constructible, is_trivially_move_constructible,
-  is_trivially_assignable, is_trivially_default_assignable,
-  is_trivially_copy_assignable, is_trivially_move_assignable
-  /entry
+  entryY/entry
+  entry/
 /row
 row
   entry20.9.5/entry
commit 4b6c1c0a6cb99c6fc7a8da5407fffed797a0bc29
Author: Jonathan Wakely jwak...@redhat.com
Date:   Thu Oct 9 13:42:57 2014 +0100

PR libstdc++/63322
* include/std/atomic (atomic): Add assertion for trivially copyable.
* testsuite/29_atomics/atomic/60695.cc: Adjust line number.

diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index be7d0be..85dc252 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -163,7 +163,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 private:
   _Tp _M_i;
 
-  // TODO: static_assert(is_trivially_copyable_Tp::value, );
+  static_assert(__is_trivially_copyable(_Tp),
+   std::atomic requires a trivially copyable type);
 
   static_assert(sizeof(_Tp)  0,
Incomplete or zero-sized types are not supported);
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
index 27c0c8f..10c5e3a 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
@@ -27,4 +27,4 @@ struct X {
   char stuff[0]; // GNU extension, type has zero size
 };
 
-std::atomicX a;  // { dg-error not supported  { target *-*-* } 168 }
+std::atomicX a;  // { dg-error not supported  { target *-*-* } 169 }
commit cfb875df06d5691b5d81de489d07c0da106da517
Author: Jonathan Wakely jwak...@redhat.com
Date:   Thu Oct 9 13:47:04 2014 +0100

PR libstdc++/61909
* include/std/functional (__is_location_invariant): Treat all
trivially copyable types as location invariant.

diff --git a/libstdc++-v3/include/std/functional 
b/libstdc++-v3/include/std/functional
index 15247bf..bed1eea 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -1743,11 +1743,12 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
   /**
*  Trait identifying location-invariant types, meaning that the
*  address of the object (or any of its members) will not escape.
-   *  Also implies a trivial copy constructor and assignment operator.
+   *  Trivially copyable types are location-invariant and users can
+   *  specialize this trait for other types.
*/
   templatetypename _Tp
 struct __is_location_invariant
-: __or_is_pointer_Tp, is_member_pointer_Tp::type
+: is_trivially_copyable_Tp::type
 { };
 
   class _Undefined_class;


[PATCH] PR libstdc++/60132, implement the remaining C++11 is_trivially_* traits

2014-10-08 Thread Ville Voutilainen
Tested on Linux-X64.

Massive thanks to Jason for doing the heavy lifting on the front-end side.

2014-10-08  Ville Voutilainen  ville.voutilai...@gmail.com

PR libstdc++/60132
* include/std/type_traits (is_trivially_copyable,
is_trivially_constructible, is_trivially_default_constructible,
is_trivially_copy_constructible, is_trivially_move_constructible,
is_trivially_assignable, is_trivially_copy_assignable,
is_trivially_move_assignable): New.
* testsuite/20_util/is_trivially_assignable/requirements/typedefs.cc: New.
* 
testsuite/20_util/is_trivially_assignable/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_assignable/value.cc: New.
* testsuite/20_util/is_trivially_constructible/requirements/typedefs.cc:
New.
* 
testsuite/20_util/is_trivially_constructible/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_constructible/value.cc: New.
* testsuite/20_util/is_trivially_copyable/requirements/typedefs.cc: New.
* 
testsuite/20_util/is_trivially_copyable/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_copyable/value.cc: New.
* testsuite/20_util/is_trivially_copy_assignable/requirements/typedefs.cc:
New.
* 
testsuite/20_util/is_trivially_copy_assignable/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_copy_assignable/value.cc: New.
* 
testsuite/20_util/is_trivially_copy_constructible/requirements/typedefs.cc:
New.
* 
testsuite/20_util/is_trivially_copy_constructible/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_copy_constructible/value.cc: New.
* 
testsuite/20_util/is_trivially_default_constructible/requirements/typedefs.cc:
New.
* 
testsuite/20_util/is_trivially_default_constructible/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_default_constructible/value.cc: New.
* testsuite/20_util/is_trivially_move_assignable/requirements/typedefs.cc:
New.
* 
testsuite/20_util/is_trivially_move_assignable/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_move_assignable/value.cc: New.
* 
testsuite/20_util/is_trivially_move_constructible/requirements/typedefs.cc:
New.
* 
testsuite/20_util/is_trivially_move_constructible/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_trivially_move_constructible/value.cc: New.
diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index 6690044..d776efe 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -606,7 +606,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 : public integral_constantbool, __is_trivial(_Tp)
 { };
 
-  // is_trivially_copyable (still unimplemented)
+  // is_trivially_copyable
+  templatetypename _Tp
+struct is_trivially_copyable
+: public integral_constantbool, __is_trivially_copyable(_Tp)
+{ };
 
   /// is_standard_layout
   templatetypename _Tp
@@ -1282,19 +1286,58 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 : public __is_nt_move_assignable_impl_Tp
 { };
 
-  /// is_trivially_constructible (still unimplemented)
+  /// is_trivially_constructible
+  templatetypename _Tp, typename... _Args
+struct is_trivially_constructible
+: public __and_is_constructible_Tp, _Args..., integral_constantbool,
+   __is_trivially_constructible(_Tp, _Args...)::type
+{ };
   
-  /// is_trivially_default_constructible (still unimplemented)
-
-  /// is_trivially_copy_constructible (still unimplemented)
+  /// is_trivially_default_constructible
+  templatetypename _Tp
+struct is_trivially_default_constructible
+: public is_trivially_constructible_Tp::type
+{ };
 
-  /// is_trivially_move_constructible (still unimplemented)
+  /// is_trivially_copy_constructible
+  templatetypename _Tp
+struct is_trivially_copy_constructible
+: public __and_is_copy_constructible_Tp, 
+   integral_constantbool,
+   __is_trivially_constructible(_Tp, const _Tp)::type
+{ };
+  
+  /// is_trivially_move_constructible
+  templatetypename _Tp
+struct is_trivially_move_constructible
+: public __and_is_move_constructible_Tp, 
+   integral_constantbool,
+   __is_trivially_constructible(_Tp, _Tp)::type
+{ };
 
-  /// is_trivially_assignable (still unimplemented)
+  /// is_trivially_assignable
+  templatetypename _Tp, typename _Up
+struct is_trivially_assignable
+: public __and_is_assignable_Tp, _Up, 
+   integral_constantbool,
+   __is_trivially_assignable(_Tp, _Up)::type
+{ };
 
-  /// is_trivially_copy_assignable (still unimplemented)
+  /// is_trivially_copy_assignable
+  templatetypename _Tp
+struct is_trivially_copy_assignable
+: public __and_is_copy_assignable_Tp, 
+   integral_constantbool,
+ 

Re: [PATCH] PR libstdc++/60132, implement the remaining C++11 is_trivially_* traits

2014-10-08 Thread Jonathan Wakely

On 08/10/14 23:28 +0300, Ville Voutilainen wrote:

   PR libstdc++/60132
   * include/std/type_traits (is_trivially_copyable,
is_trivially_constructible, is_trivially_default_constructible,
is_trivially_copy_constructible, is_trivially_move_constructible,
is_trivially_assignable, is_trivially_copy_assignable,
is_trivially_move_assignable): New.
   * testsuite/20_util/is_trivially_assignable/requirements/typedefs.cc: New.
   * 
testsuite/20_util/is_trivially_assignable/requirements/explicit_instantiation.cc:
New.


Some of the tests have copyright dates of 2012-2014 - I think they
should be just 2014, even if you copied existing files.

Please break the ChangeLog entries to fit in 80 columns, e.g.

* testsuite/20_util/is_trivially_assignable/requirements/
   explicit_instantiation.cc: New.


Other than those minor points this is OK for trunk, thanks very much!