Patchwork [v3] constexpr complex, chrono, memory

login
register
mail settings
Submitter Benjamin Kosnik
Date Nov. 24, 2010, 12:19 a.m.
Message ID <20101123161912.41d400cc@shotwell>
Download mbox | patch
Permalink /patch/72782/
State New
Headers show

Comments

Benjamin Kosnik - Nov. 24, 2010, 12:19 a.m.
Assorted constexpr additions. 

Jonathan had suggested constexpr ctors for future, and
shared_future. Thus added. Remaining: unique_lock, exception_ptr?

Added tests for constexpr constructors for non-literal classes. This is
similar to the tests in the g++ testsuite, but instead of looking for
static_initialization_and_destruction, look for named constexpr
contructor. As discussed with Jason in Batavia. There was some thought
of providing an attribute syntax for this, say something like
__attribute__((init_constant)) that would warn when the variable
wasn't constant initialized. I'm still in favor of that, (Have added
this syntax to PR45923) but will use this method as the best currently
available. 

tested x86_64/linux

-benjamin

Patch

2010-11-23  Benjamin Kosnik  <bkoz@redhat.com>

	* include/std/chrono: Constexpr markup for is_monotonic.
	* src/chrono.cc: Same.
	* testsuite/20_util/clocks/1.cc: Move...
	* testsuite/20_util/system_clock/1.cc: ...here.
	* testsuite/20_util/system_clock/constexpr_data.cc
	* testsuite/20_util/monotonic_clock/constexpr_data.cc

	* include/std/complex: Mark primary template constexpr.
	* testsuite/26_numerics/complex/cons/constexpr_primary.cc: Add.
	* testsuite/26_numerics/complex/complex_value.cc: Move...
	* testsuite/26_numerics/complex/dr387.cc: Move...
	* testsuite/26_numerics/complex/value_operations/1.cc: ... here.
	* testsuite/26_numerics/complex/value_operations/dr387.cc: ...here.
	* testsuite/26_numerics/complex/value_operations/constexpr.cc: New.

2010-11-23  Benjamin Kosnik  <bkoz@redhat.com>
	    Jason Merrill  <jason@redhat.com>

	* testsuite/lib/libstdc++.exp: Use scanasm.
	* testsuite/util/testsuite_common_types.h
	(constexpr_default_constructible): Add support for non-literal types.
	(constexpr_single_value_constructible): Same.
	* testsuite/20_util/enable_shared_from_this/cons/constexpr.cc:
	Remove xfail.
	* testsuite/20_util/shared_ptr/cons/constexpr.cc: Add.
	* testsuite/20_util/unique_ptr/cons/constexpr.cc: Add.
	* testsuite/20_util/weak_ptr/cons/constexpr.cc: Add.
	* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust line number.

2010-11-23  Benjamin Kosnik  <bkoz@redhat.com>
	    Jonathan Wakely  <jwakely.gcc@gmail.com>

	* include/std/future (shared_future): Default ctor constexpr.
	(future): Same.
	* testsuite/30_threads/shared_future/cons/constexpr.cc: New.
	* testsuite/30_threads/future/cons/constexpr.cc: New.

Index: src/chrono.cc
===================================================================
--- src/chrono.cc	(revision 167095)
+++ src/chrono.cc	(working copy)
@@ -37,7 +37,7 @@ 
 
   namespace chrono
   {
-    const bool system_clock::is_monotonic;
+    constexpr bool system_clock::is_monotonic;
 
     system_clock::time_point
     system_clock::now() throw ()
@@ -61,7 +61,7 @@ 
     }
     
 #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
-    const bool monotonic_clock::is_monotonic;
+    constexpr bool monotonic_clock::is_monotonic;
     
     monotonic_clock::time_point
     monotonic_clock::now()
Index: include/std/future
===================================================================
--- include/std/future	(revision 167095)
+++ include/std/future	(working copy)
@@ -556,7 +556,7 @@ 
       explicit
       __basic_future(future<_Res>&&);
 
-      __basic_future() { }
+      constexpr __basic_future() : _M_state() { }
 
       struct _Reset
       {
@@ -584,7 +584,7 @@ 
       future(const __state_type& __state) : _Base_type(__state) { }
 
     public:
-      future() : _Base_type() { }
+      constexpr future() : _Base_type() { }
 
       /// Move constructor
       future(future&& __uf) : _Base_type(std::move(__uf)) { }
@@ -625,7 +625,7 @@ 
       future(const __state_type& __state) : _Base_type(__state) { }
 
     public:
-      future() : _Base_type() { }
+      constexpr future() : _Base_type() { }
 
       /// Move constructor
       future(future&& __uf) : _Base_type(std::move(__uf)) { }
@@ -666,7 +666,7 @@ 
       future(const __state_type& __state) : _Base_type(__state) { }
 
     public:
-      future() : _Base_type() { }
+      constexpr future() : _Base_type() { }
 
       /// Move constructor
       future(future&& __uf) : _Base_type(std::move(__uf)) { }
@@ -698,7 +698,7 @@ 
       typedef __basic_future<_Res> _Base_type;
 
     public:
-      shared_future() : _Base_type() { }
+      constexpr shared_future() : _Base_type() { }
 
       /// Copy constructor
       shared_future(const shared_future& __sf) : _Base_type(__sf) { }
@@ -742,7 +742,7 @@ 
       typedef __basic_future<_Res&>           _Base_type;
 
     public:
-      shared_future() : _Base_type() { }
+      constexpr shared_future() : _Base_type() { }
 
       /// Copy constructor
       shared_future(const shared_future& __sf) : _Base_type(__sf) { }
@@ -781,7 +781,7 @@ 
       typedef __basic_future<void> _Base_type;
 
     public:
-      shared_future() : _Base_type() { }
+      constexpr shared_future() : _Base_type() { }
 
       /// Copy constructor
       shared_future(const shared_future& __sf) : _Base_type(__sf) { }
Index: include/std/chrono
===================================================================
--- include/std/chrono	(revision 167095)
+++ include/std/chrono	(working copy)
@@ -228,7 +228,7 @@ 
 			 && (treat_as_floating_point<rep>::value
 			     || !treat_as_floating_point<_Rep2>::value)>::type>
 	  constexpr explicit duration(const _Rep2& __rep)
-	    : __r(static_cast<rep>(__rep)) { }
+	  : __r(static_cast<rep>(__rep)) { }
 
 	template<typename _Rep2, typename _Period2, typename = typename
 	       enable_if<treat_as_floating_point<rep>::value
@@ -644,22 +644,22 @@ 
     struct system_clock
     {
 #ifdef _GLIBCXX_USE_CLOCK_REALTIME
-      typedef chrono::nanoseconds     duration;
+      typedef chrono::nanoseconds     				duration;
 #elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
-      typedef chrono::microseconds    duration;
+      typedef chrono::microseconds    				duration;
 #else
-      typedef chrono::seconds         duration;
+      typedef chrono::seconds         				duration;
 #endif
 
-      typedef duration::rep    rep;
-      typedef duration::period period;
-      typedef chrono::time_point<system_clock, duration> time_point;
+      typedef duration::rep    					rep;
+      typedef duration::period 					period;
+      typedef chrono::time_point<system_clock, duration> 	time_point;
 
       static_assert(system_clock::duration::min()
 		    < system_clock::duration::zero(),
 		    "a clock's minimum duration cannot be less than its epoch");
 
-      static const bool is_monotonic = false;
+      static constexpr bool is_monotonic = false;
 
       static time_point
       now() throw ();
@@ -685,12 +685,12 @@ 
     /// monotonic_clock
     struct monotonic_clock
     {
-      typedef chrono::nanoseconds duration;
-      typedef duration::rep       rep;
-      typedef duration::period    period;
-      typedef chrono::time_point<monotonic_clock, duration> time_point;
+      typedef chrono::nanoseconds 				duration;
+      typedef duration::rep       				rep;
+      typedef duration::period    				period;
+      typedef chrono::time_point<monotonic_clock, duration> 	time_point;
 
-      static const bool is_monotonic = true;
+      static constexpr bool is_monotonic = true;
 
       static time_point
       now();
Index: include/std/complex
===================================================================
--- include/std/complex	(revision 167095)
+++ include/std/complex	(working copy)
@@ -529,12 +529,12 @@ 
   // Values
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
   template<typename _Tp>
-    inline _Tp
+    inline constexpr _Tp
     real(const complex<_Tp>& __z)
     { return __z.real(); }
     
   template<typename _Tp>
-    inline _Tp
+    inline constexpr _Tp
     imag(const complex<_Tp>& __z)
     { return __z.imag(); }
 #else
Index: testsuite/30_threads/shared_future/cons/constexpr.cc
===================================================================
--- testsuite/30_threads/shared_future/cons/constexpr.cc	(revision 0)
+++ testsuite/30_threads/shared_future/cons/constexpr.cc	(revision 0)
@@ -0,0 +1,32 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x -fno-inline -save-temps" }
+// { dg-final { scan-assembler-not "_ZNSt13shared_futureIvEC2Ev" } }
+// { dg-final { scan-assembler-not "_ZNSt13shared_futureIiEC2Ev" } }
+
+// Copyright (C) 2010 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 <future>
+#include <testsuite_common_types.h>
+
+int main()
+{
+  __gnu_test::constexpr_default_constructible test; //not literal
+  test.operator()<std::shared_future<int>>();
+  test.operator()<std::shared_future<void>>();
+  return 0;
+}
Index: testsuite/30_threads/future/cons/constexpr.cc
===================================================================
--- testsuite/30_threads/future/cons/constexpr.cc	(revision 0)
+++ testsuite/30_threads/future/cons/constexpr.cc	(revision 0)
@@ -0,0 +1,32 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x -fno-inline -save-temps" }
+// { dg-final { scan-assembler-not "_ZNSt6futureIvEC2Ev" } }
+// { dg-final { scan-assembler-not "_ZNSt6futureIiEC2Ev" } }
+
+// Copyright (C) 2010 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 <future>
+#include <testsuite_common_types.h>
+
+int main()
+{
+  __gnu_test::constexpr_default_constructible test; //not literal
+  test.operator()<std::future<int>>();
+  test.operator()<std::future<void>>();
+  return 0;
+}
Index: testsuite/26_numerics/complex/value_operations/constexpr.cc
===================================================================
--- testsuite/26_numerics/complex/value_operations/constexpr.cc	(revision 0)
+++ testsuite/26_numerics/complex/value_operations/constexpr.cc	(revision 0)
@@ -0,0 +1,57 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 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 <complex>
+#include <testsuite_common_types.h>
+
+namespace __gnu_test
+{
+  struct constexpr_functions
+  {
+    template<typename _Ttesttype>
+      void
+      operator()()
+      {
+	struct _Concept
+	{
+	  void __constraint()
+	  { 
+	    typedef typename _Ttesttype::_ComplexT _ComplexT;
+	    const _ComplexT cc = { 1.1 };
+	    constexpr _Ttesttype a(cc);
+	    constexpr auto v1 __attribute__((unused)) = real(a);
+	    constexpr auto v2 __attribute__((unused)) = imag(a);
+	  }
+	};
+
+	_Concept c;
+	c.__constraint();
+      }
+  };
+}
+
+int main()
+{
+  __gnu_test::constexpr_functions test;
+  test.operator()<std::complex<float>>();
+  test.operator()<std::complex<double>>();
+  test.operator()<std::complex<long double>>();
+  return 0;
+}
Index: testsuite/26_numerics/complex/cons/constexpr_primary.cc
===================================================================
--- testsuite/26_numerics/complex/cons/constexpr_primary.cc	(revision 0)
+++ testsuite/26_numerics/complex/cons/constexpr_primary.cc	(revision 0)
@@ -0,0 +1,67 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 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 <complex>
+
+// User defined type, so that the primary std::complex template is used.
+namespace numext
+{
+  struct ldld_base
+  {
+    long double one;
+    long double two;
+  };
+
+  struct ldld_lit : public ldld_base
+  { };
+
+  struct ldld_nonlit : public ldld_base
+  {
+    ~ldld_nonlit() { }
+  };
+
+  bool
+  operator<(const ldld_base __a, const ldld_base __b)
+  { return __a.one < __b.one && __a.two < __b.two; }
+
+  bool
+  operator==(const ldld_base __a, const ldld_base __b)
+  { return __a.one == __b.one && __a.two == __b.two; }
+
+  ldld_base
+  operator+=(const ldld_base __a, const ldld_base __b)
+  { return ldld_base({ __a.one + __b.one, __a.two + __b.two}); }
+
+  ldld_base
+  operator-=(const ldld_base __a, const ldld_base __b)
+  { return ldld_base({ __a.one - __b.one, __a.two - __b.two}); }
+
+  ldld_base
+  operator*=(const ldld_base __a, const ldld_base __b)
+  { return ldld_base({ __a.one * __b.one, __a.two * __b.two}); }
+
+  ldld_base
+  operator/=(const ldld_base __a, const ldld_base __b)
+  { return ldld_base({ __a.one / __b.one, __a.two / __b.two}); }
+
+}
+
+constexpr std::complex<numext::ldld_lit> lit; // ok
+// constexpr std::complex<numext::ldld_nonlit> nonlit; // error
Index: testsuite/26_numerics/complex/complex_value.cc
===================================================================
--- testsuite/26_numerics/complex/complex_value.cc	(revision 167095)
+++ testsuite/26_numerics/complex/complex_value.cc	(working copy)
@@ -1,65 +0,0 @@ 
-// { dg-do run { xfail broken_cplxf_arg } }
-// { dg-options "-O0" }
-// 2000-11-20
-// Benjamin Kosnik bkoz@redhat.com
-
-// Copyright (C) 2000, 2003, 2004, 2009, 2010 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 <complex>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- using namespace std;
- bool test __attribute__((unused)) = true;
- typedef complex<double> complex_type;
- const double cd1 = -11.451;
- const double cd2 = -442.1533;
-
- complex_type a(cd1, cd2);
- double d;
- d = a.real();
- VERIFY( d == cd1 );
-
- d = a.imag();
- VERIFY( d == cd2 );
-
- complex_type c(cd1, cd2);
- double d6 = abs(c);
- VERIFY( d6 >= 0 );
-
- double d7 = arg(c);
- double d8 = atan2(c.imag(), c.real());
- VERIFY( d7 == d8 );
-
- double d9 = norm(c);
- double d10 = d6 * d6;
- VERIFY( d9 - d10 == 0 );
-
- complex_type e __attribute__((unused)) = conj(c);
- 
- complex_type f = polar(c.imag(), 0.0);
- VERIFY( f.real() != 0 );
-}
-
-
-int main()
-{
-  test01();
-  return 0;
-}
Index: testsuite/26_numerics/complex/dr387.cc
===================================================================
--- testsuite/26_numerics/complex/dr387.cc	(revision 167095)
+++ testsuite/26_numerics/complex/dr387.cc	(working copy)
@@ -1,51 +0,0 @@ 
-// 2008-05-22  Paolo Carlini  <paolo.carlini@oracle.com>
-//
-// Copyright (C) 2008, 2009 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 <complex>
-#include <testsuite_hooks.h>
-
-// DR 387. std::complex over-encapsulated.
-template<typename T>
-  void
-  do_test()
-  {
-    bool test __attribute__((unused)) = true;
-
-    const T r = 1.0;
-    const T i = -1.0;
-    const T v = 0.0;
-
-    std::complex<T> z1(r, i);
-    z1.real(v);
-    VERIFY( z1.real() == v );
-    VERIFY( z1.imag() == i );
-
-    std::complex<T> z2(r, i);
-    z2.imag(v);
-    VERIFY( z2.real() == r );
-    VERIFY( z2.imag() == v );
-  }
-
-int main()
-{
-  do_test<float>();
-  do_test<double>();
-  do_test<long double>();
-  return 0;
-}
Index: testsuite/lib/libstdc++.exp
===================================================================
--- testsuite/lib/libstdc++.exp	(revision 167095)
+++ testsuite/lib/libstdc++.exp	(working copy)
@@ -51,6 +51,7 @@ 
 load_gcc_lib target-supports-dg.exp
 load_lib prune.exp
 load_lib dg-options.exp
+load_gcc_lib scanasm.exp
 load_gcc_lib target-libpath.exp
 load_gcc_lib timeout.exp
 load_gcc_lib timeout-dg.exp
Index: testsuite/util/testsuite_common_types.h
===================================================================
--- testsuite/util/testsuite_common_types.h	(revision 167095)
+++ testsuite/util/testsuite_common_types.h	(working copy)
@@ -637,50 +637,77 @@ 
       }
   };
 
-  // Generator to test constexpr constructor
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
   // Generator to test default constructor.
   struct constexpr_default_constructible
   {
+    template<typename _Tp, bool _IsLitp = std::is_literal_type<_Tp>::value>
+      struct _Concept;
+
     // NB: _Tp must be a literal type. 
+    // Have to have user-defined default ctor for this to work.
     template<typename _Tp>
+      struct _Concept<_Tp, true>
+      {
+	void __constraint()
+	{ constexpr _Tp __obj; }
+      };
+
+    // Non-literal type, declare local static and verify no
+    // constructors generated for _Tp within the translation unit.
+    template<typename _Tp>
+      struct _Concept<_Tp, false>
+      {
+	void __constraint()
+	{ static _Tp __obj; }
+      };
+
+    template<typename _Tp>
       void 
       operator()()
       {
-	struct _Concept
-	{
-	  // Have to have user-defined default ctor for this to work.
-	  void __constraint()
-	  { constexpr _Tp __v; }
-	};
-
-	void (_Concept::*__x)() __attribute__((unused))
-	  = &_Concept::__constraint;
+	_Concept<_Tp> c;
+	c.__constraint();
       }
   };
 
   struct constexpr_single_value_constructible
   {
-    // NB: _Tbasetype and _Ttesttype must be literal types. 
-    template<typename _Ttesttype, typename _Tbasetype>
+    template<typename _Ttesttype, typename _Tvaluetype, 
+	     bool _IsLitp = std::is_literal_type<_Ttesttype>::value>
+      struct _Concept;
+
+    // NB: _Tvaluetype and _Ttesttype must be literal types.
+    // Additional constraint on _Tvaluetype needed.  Either assume
+    // user-defined default ctor as per
+    // constexpr_default_constructible and provide no initializer,
+    // provide an initializer, or assume empty-list init-able. Choose
+    // the latter.
+    template<typename _Ttesttype, typename _Tvaluetype>
+      struct _Concept<_Ttesttype, _Tvaluetype, true>
+      {
+	void __constraint()
+	{
+	  constexpr _Tvaluetype __v { };
+	  constexpr _Ttesttype __obj(__v);
+	}
+      };
+
+    template<typename _Ttesttype, typename _Tvaluetype>
+      struct _Concept<_Ttesttype, _Tvaluetype, false>
+      {
+	void __constraint()
+	{ 
+	  const _Tvaluetype __v { };
+	  static _Ttesttype __obj(__v);
+	}
+      };
+
+    template<typename _Ttesttype, typename _Tvaluetype>
       void
       operator()()
       {
-	struct _Concept
-	{
-	  // Additional constraint on _Tbasetype needed.
-	  // Either assume user-defined default ctor as per
-	  // constexpr_default_constructible and provide no
-	  // initializer, provide an initializer, or assume empty-list
-	  // init-able. Choose the latter.
-	  void __constraint()
-	  {
-	    constexpr _Tbasetype __v { };
-	    constexpr _Ttesttype __t(__v);
-	  }
-	};
-
-	_Concept c;
+	_Concept<_Ttesttype, _Tvaluetype> c;
 	c.__constraint();
       }
   };
Index: testsuite/20_util/monotonic_clock/constexpr_data.cc
===================================================================
--- testsuite/20_util/monotonic_clock/constexpr_data.cc	(revision 0)
+++ testsuite/20_util/monotonic_clock/constexpr_data.cc	(revision 0)
@@ -0,0 +1,52 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 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 <chrono>
+#include <testsuite_common_types.h>
+
+namespace __gnu_test
+{
+  struct constexpr_member_data
+  {
+    template<typename _Ttesttype>
+      void
+      operator()()
+      {
+	struct _Concept
+	{
+	  void __constraint()
+	  {
+	    constexpr auto v1 __attribute__((unused))
+	      = _Ttesttype::is_monotonic;
+	  }
+	};
+
+	_Concept c;
+	c.__constraint();
+      }
+  };
+}
+
+int main()
+{
+  __gnu_test::constexpr_member_data test;
+  test.operator()<std::chrono::monotonic_clock>();
+  return 0;
+}
Index: testsuite/20_util/enable_shared_from_this/cons/constexpr.cc
===================================================================
--- testsuite/20_util/enable_shared_from_this/cons/constexpr.cc	(revision 167095)
+++ testsuite/20_util/enable_shared_from_this/cons/constexpr.cc	(working copy)
@@ -1,5 +1,7 @@ 
-// { dg-do compile { xfail *-*-* } }
-// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+// { dg-options "-std=gnu++0x -fno-inline -save-temps" }
+// { dg-final { scan-assembler-not "_ZNSt23enable_shared_from_thisIiEC2Ev" } }
+// { dg-final { scan-assembler-not "_ZN7derivedC2Ev" } }
 
 // Copyright (C) 2010 Free Software Foundation, Inc.
 //
@@ -29,7 +31,6 @@ 
 int main()
 {
   __gnu_test::constexpr_default_constructible test;
-  test.operator()<derived>();  // { dg-excess-errors "" }
-  derived d;
+  test.operator()<derived>();
   return 0;
 }
Index: testsuite/20_util/clocks/1.cc
===================================================================
--- testsuite/20_util/clocks/1.cc	(revision 167095)
+++ testsuite/20_util/clocks/1.cc	(working copy)
@@ -1,39 +0,0 @@ 
-// { dg-options "-std=gnu++0x" }
-// { dg-require-cstdint "" }
-
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation
-//
-// 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/>.
-
-// 20.8.5 Clocks [time.clock]
-
-#include <chrono>
-
-// 20.8.5.1 system_clock [time.clock.system]
-int
-main()
-{
-  using namespace std::chrono;
-
-  system_clock::time_point t1 = system_clock::now();
-  bool is_monotonic = system_clock::is_monotonic;
-  is_monotonic = is_monotonic; // suppress unused warning
-  std::time_t t2 = system_clock::to_time_t(t1);
-  system_clock::time_point t3 = system_clock::from_time_t(t2);
-  t3 = t3; // suppress unused warning
-  
-  return 0;
-}
Index: testsuite/20_util/shared_ptr/cons/constexpr.cc
===================================================================
--- testsuite/20_util/shared_ptr/cons/constexpr.cc	(revision 0)
+++ testsuite/20_util/shared_ptr/cons/constexpr.cc	(revision 0)
@@ -0,0 +1,35 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x -fno-inline -save-temps" }
+// { dg-final { scan-assembler-not "_ZNSt10shared_ptrIiEC2Ev" } }
+// { dg-final { scan-assembler-not "_ZNSt10shared_ptrIiEC2EDn" } }
+
+// Copyright (C) 2010 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 <memory>
+#include <testsuite_common_types.h>
+
+int main()
+{
+  __gnu_test::constexpr_default_constructible test1;  //not literal
+  test1.operator()<std::shared_ptr<int>>();
+
+  __gnu_test::constexpr_single_value_constructible test2;  //not literal
+  test2.operator()<std::shared_ptr<int>, std::nullptr_t>();
+
+  return 0;
+}
Index: testsuite/20_util/unique_ptr/cons/constexpr.cc
===================================================================
--- testsuite/20_util/unique_ptr/cons/constexpr.cc	(revision 0)
+++ testsuite/20_util/unique_ptr/cons/constexpr.cc	(revision 0)
@@ -0,0 +1,35 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x -fno-inline -save-temps" }
+// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2Ev" } }
+// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2EDn" } }
+
+// Copyright (C) 2010 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 <memory>
+#include <testsuite_common_types.h>
+
+int main()
+{
+  __gnu_test::constexpr_default_constructible test1;  //not literal
+  test1.operator()<std::unique_ptr<int>>();
+
+  __gnu_test::constexpr_single_value_constructible test2;  //not literal
+  test2.operator()<std::unique_ptr<int>, std::nullptr_t>();
+
+  return 0;
+}
Index: testsuite/20_util/system_clock/constexpr_data.cc
===================================================================
--- testsuite/20_util/system_clock/constexpr_data.cc	(revision 0)
+++ testsuite/20_util/system_clock/constexpr_data.cc	(revision 0)
@@ -0,0 +1,52 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 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 <chrono>
+#include <testsuite_common_types.h>
+
+namespace __gnu_test
+{
+  struct constexpr_member_data
+  {
+    template<typename _Ttesttype>
+      void
+      operator()()
+      {
+	struct _Concept
+	{
+	  void __constraint()
+	  {
+	    constexpr auto v1 __attribute__((unused))
+	      = _Ttesttype::is_monotonic;
+	  }
+	};
+
+	_Concept c;
+	c.__constraint();
+      }
+  };
+}
+
+int main()
+{
+  __gnu_test::constexpr_member_data test;
+  test.operator()<std::chrono::system_clock>();
+  return 0;
+}
Index: testsuite/20_util/weak_ptr/cons/constexpr.cc
===================================================================
--- testsuite/20_util/weak_ptr/cons/constexpr.cc	(revision 0)
+++ testsuite/20_util/weak_ptr/cons/constexpr.cc	(revision 0)
@@ -0,0 +1,30 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++0x -fno-inline -save-temps" }
+// { dg-final { scan-assembler-not "_ZNSt8weak_ptrIiEC2Ev" } }
+
+// Copyright (C) 2010 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 <memory>
+#include <testsuite_common_types.h>
+
+int main()
+{
+  __gnu_test::constexpr_default_constructible test; //not literal
+  test.operator()<std::weak_ptr<int>>();
+  return 0;
+}