OSDN Git Service

2010-11-23 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Nov 2010 23:47:44 +0000 (23:47 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Nov 2010 23:47:44 +0000 (23:47 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167099 138bc75d-0d04-0410-961f-82ee72b054a4

20 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/chrono
libstdc++-v3/include/std/complex
libstdc++-v3/include/std/future
libstdc++-v3/src/chrono.cc
libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc
libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/system_clock/1.cc [moved from libstdc++-v3/testsuite/20_util/clocks/1.cc with 100% similarity]
libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc [moved from libstdc++-v3/testsuite/26_numerics/complex/complex_value.cc with 100% similarity]
libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc [moved from libstdc++-v3/testsuite/26_numerics/complex/dr387.cc with 100% similarity]
libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc [new file with mode: 0644]
libstdc++-v3/testsuite/lib/libstdc++.exp
libstdc++-v3/testsuite/util/testsuite_common_types.h

index 5dc04d3..144126a 100644 (file)
@@ -1,3 +1,42 @@
+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.
+
 2010-11-23  Uros Bizjak  <ubizjak@gmail.com>
 
        * testsuite/22_locale/collate/hash/char/wrapped_locale.cc: Require
index c4dcbd5..2511081 100644 (file)
@@ -228,7 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
                         && (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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     /// 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 ffdadc3..4bd8e8c 100644 (file)
@@ -529,12 +529,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   // 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 0c36795..4569116 100644 (file)
@@ -556,7 +556,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       explicit
       __basic_future(future<_Res>&&);
 
-      __basic_future() { }
+      constexpr __basic_future() : _M_state() { }
 
       struct _Reset
       {
@@ -584,7 +584,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       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 699a10a..4dcd74b 100644 (file)
@@ -37,7 +37,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
   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 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     }
     
 #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 0df6dcf..f66944b 100644 (file)
@@ -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 @@ struct derived : public std::enable_shared_from_this<int>
 int main()
 {
   __gnu_test::constexpr_default_constructible test;
-  test.operator()<derived>();  // { dg-excess-errors "" }
-  derived d;
+  test.operator()<derived>();
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc b/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc
new file mode 100644 (file)
index 0000000..34477ea
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc
new file mode 100644 (file)
index 0000000..72eea9e
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc b/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc
new file mode 100644 (file)
index 0000000..2407ef1
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc
new file mode 100644 (file)
index 0000000..1f3cabc
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc
new file mode 100644 (file)
index 0000000..ce19df1
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc
new file mode 100644 (file)
index 0000000..77e01bc
--- /dev/null
@@ -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
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc
new file mode 100644 (file)
index 0000000..29728a2
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc b/libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc
new file mode 100644 (file)
index 0000000..0045f7c
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc
new file mode 100644 (file)
index 0000000..6c661f2
--- /dev/null
@@ -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 dd717d9..36b6e86 100644 (file)
@@ -51,6 +51,7 @@ load_gcc_lib target-supports.exp
 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 c78f945..0960b79 100644 (file)
@@ -637,50 +637,77 @@ namespace __gnu_test
       }
   };
 
-  // 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>
-      void
-      operator()()
+    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>
       {
-       struct _Concept
+       void __constraint()
        {
-         // 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);
-         }
-       };
+         constexpr _Tvaluetype __v { };
+         constexpr _Ttesttype __obj(__v);
+       }
+      };
 
-       _Concept c;
+    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()()
+      {
+       _Concept<_Ttesttype, _Tvaluetype> c;
        c.__constraint();
       }
   };