From bcafd86c962fd9eea1aac63b9ea81daf109a7b33 Mon Sep 17 00:00:00 2001 From: bkoz Date: Tue, 23 Nov 2010 23:47:44 +0000 Subject: [PATCH] 2010-11-23 Benjamin Kosnik * 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 Jason Merrill * 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 Jonathan Wakely * 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 --- libstdc++-v3/ChangeLog | 39 +++++++++++ libstdc++-v3/include/std/chrono | 26 +++---- libstdc++-v3/include/std/complex | 4 +- libstdc++-v3/include/std/future | 14 ++-- libstdc++-v3/src/chrono.cc | 4 +- .../enable_shared_from_this/cons/constexpr.cc | 9 +-- .../20_util/monotonic_clock/constexpr_data.cc | 52 ++++++++++++++ .../testsuite/20_util/shared_ptr/cons/constexpr.cc | 35 ++++++++++ .../20_util/{clocks => system_clock}/1.cc | 0 .../20_util/system_clock/constexpr_data.cc | 52 ++++++++++++++ .../testsuite/20_util/unique_ptr/cons/constexpr.cc | 35 ++++++++++ .../testsuite/20_util/weak_ptr/cons/constexpr.cc | 30 ++++++++ .../26_numerics/complex/cons/constexpr_primary.cc | 67 ++++++++++++++++++ .../{complex_value.cc => value_operations/1.cc} | 0 .../complex/value_operations/constexpr.cc | 57 +++++++++++++++ .../complex/{ => value_operations}/dr387.cc | 0 .../testsuite/30_threads/future/cons/constexpr.cc | 32 +++++++++ .../30_threads/shared_future/cons/constexpr.cc | 32 +++++++++ libstdc++-v3/testsuite/lib/libstdc++.exp | 1 + .../testsuite/util/testsuite_common_types.h | 81 ++++++++++++++-------- 20 files changed, 515 insertions(+), 55 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc rename libstdc++-v3/testsuite/20_util/{clocks => system_clock}/1.cc (100%) create mode 100644 libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc rename libstdc++-v3/testsuite/26_numerics/complex/{complex_value.cc => value_operations/1.cc} (100%) create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc rename libstdc++-v3/testsuite/26_numerics/complex/{ => value_operations}/dr387.cc (100%) create mode 100644 libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5dc04d37bbb..144126aca9d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,42 @@ +2010-11-23 Benjamin Kosnik + + * 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 + Jason Merrill + + * 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 + Jonathan Wakely + + * 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 * testsuite/22_locale/collate/hash/char/wrapped_locale.cc: Require diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index c4dcbd5f67f..25110817a15 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -228,7 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) && (treat_as_floating_point::value || !treat_as_floating_point<_Rep2>::value)>::type> constexpr explicit duration(const _Rep2& __rep) - : __r(static_cast(__rep)) { } + : __r(static_cast(__rep)) { } template::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 time_point; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point 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 time_point; + typedef chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point time_point; - static const bool is_monotonic = true; + static constexpr bool is_monotonic = true; static time_point now(); diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index ffdadc3757e..4bd8e8c42e1 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -529,12 +529,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Values #ifdef __GXX_EXPERIMENTAL_CXX0X__ template - inline _Tp + inline constexpr _Tp real(const complex<_Tp>& __z) { return __z.real(); } template - inline _Tp + inline constexpr _Tp imag(const complex<_Tp>& __z) { return __z.imag(); } #else diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index 0c367955914..45691168f3f 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -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 _Base_type; public: - shared_future() : _Base_type() { } + constexpr shared_future() : _Base_type() { } /// Copy constructor shared_future(const shared_future& __sf) : _Base_type(__sf) { } diff --git a/libstdc++-v3/src/chrono.cc b/libstdc++-v3/src/chrono.cc index 699a10a7253..4dcd74bcee3 100644 --- a/libstdc++-v3/src/chrono.cc +++ b/libstdc++-v3/src/chrono.cc @@ -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() diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc index 0df6dcf3896..f66944b3a90 100644 --- a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc @@ -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 main() { __gnu_test::constexpr_default_constructible test; - test.operator()(); // { dg-excess-errors "" } - derived d; + test.operator()(); 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 index 00000000000..34477ea1838 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc @@ -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 +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_data + { + template + 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()(); + 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 index 00000000000..72eea9e0ffc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc @@ -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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; //not literal + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; //not literal + test2.operator(), std::nullptr_t>(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/clocks/1.cc b/libstdc++-v3/testsuite/20_util/system_clock/1.cc similarity index 100% rename from libstdc++-v3/testsuite/20_util/clocks/1.cc rename to libstdc++-v3/testsuite/20_util/system_clock/1.cc 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 index 00000000000..2407ef16a71 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc @@ -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 +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_data + { + template + 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()(); + 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 index 00000000000..1f3cabc789a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc @@ -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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; //not literal + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; //not literal + test2.operator(), 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 index 00000000000..ce19df1578d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc @@ -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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test; //not literal + test.operator()>(); + 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 index 00000000000..77e01bcff00 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc @@ -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 +// . + +#include + +// 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 lit; // ok +// constexpr std::complex nonlit; // error diff --git a/libstdc++-v3/testsuite/26_numerics/complex/complex_value.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc similarity index 100% rename from libstdc++-v3/testsuite/26_numerics/complex/complex_value.cc rename to libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc 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 index 00000000000..29728a2b3e0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc @@ -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 +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_functions + { + template + 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()>(); + test.operator()>(); + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr387.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc similarity index 100% rename from libstdc++-v3/testsuite/26_numerics/complex/dr387.cc rename to libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc 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 index 00000000000..0045f7ca7ae --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc @@ -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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test; //not literal + test.operator()>(); + test.operator()>(); + 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 index 00000000000..6c661f21d06 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc @@ -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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test; //not literal + test.operator()>(); + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index dd717d97396..36b6e864f10 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -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 diff --git a/libstdc++-v3/testsuite/util/testsuite_common_types.h b/libstdc++-v3/testsuite/util/testsuite_common_types.h index c78f9450417..0960b7916c4 100644 --- a/libstdc++-v3/testsuite/util/testsuite_common_types.h +++ b/libstdc++-v3/testsuite/util/testsuite_common_types.h @@ -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::value> + struct _Concept; + // NB: _Tp must be a literal type. + // Have to have user-defined default ctor for this to work. + template + 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 + struct _Concept<_Tp, false> + { + void __constraint() + { static _Tp __obj; } + }; + template 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 - void - operator()() + template::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 + 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 + struct _Concept<_Ttesttype, _Tvaluetype, false> + { + void __constraint() + { + const _Tvaluetype __v { }; + static _Ttesttype __obj(__v); + } + }; + + template + void + operator()() + { + _Concept<_Ttesttype, _Tvaluetype> c; c.__constraint(); } }; -- 2.11.0