diff options
Diffstat (limited to 'gcc-4.4.3/libstdc++-v3/testsuite/20_util')
232 files changed, 12819 insertions, 0 deletions
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..aa1dc3759 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct add_lvalue_reference<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc new file mode 100644 index 000000000..189f4457b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::add_lvalue_reference; + using std::is_same; + using namespace __gnu_test; + + VERIFY( (is_same<add_lvalue_reference<int>::type, int&>::value) ); + VERIFY( (is_same<add_lvalue_reference<int&>::type, int&>::value) ); + VERIFY( (is_same<add_lvalue_reference<const int>::type, const int&>::value) ); + VERIFY( (is_same<add_lvalue_reference<int*>::type, int*&>::value) ); + VERIFY( (is_same<add_lvalue_reference<ClassType&>::type, ClassType&>::value) ); + VERIFY( (is_same<add_lvalue_reference<ClassType>::type, ClassType&>::value) ); + VERIFY( (is_same<add_lvalue_reference<int(int)>::type, int(&)(int)>::value) ); + VERIFY( (is_same<add_lvalue_reference<int&&>::type, int&>::value) ); + VERIFY( (is_same<add_lvalue_reference<ClassType&&>::type, ClassType&>::value) ); + VERIFY( (is_same<add_lvalue_reference<void>::type, void>::value) ); + VERIFY( (is_same<add_lvalue_reference<const void>::type, const void>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..c99902816 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct add_rvalue_reference<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc new file mode 100644 index 000000000..397178cfe --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::add_rvalue_reference; + using std::is_same; + using namespace __gnu_test; + + VERIFY( (is_same<add_rvalue_reference<int>::type, int&&>::value) ); + VERIFY( (is_same<add_rvalue_reference<int&&>::type, int&&>::value) ); + VERIFY( (is_same<add_rvalue_reference<const int>::type, const int&&>::value) ); + VERIFY( (is_same<add_rvalue_reference<int*>::type, int*&&>::value) ); + VERIFY( (is_same<add_rvalue_reference<ClassType&&>::type, ClassType&&>::value) ); + VERIFY( (is_same<add_rvalue_reference<ClassType>::type, ClassType&&>::value) ); + VERIFY( (is_same<add_rvalue_reference<int(int)>::type, int(&&)(int)>::value) ); + VERIFY( (is_same<add_rvalue_reference<void>::type, void>::value) ); + VERIFY( (is_same<add_rvalue_reference<const void>::type, const void>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6186d8e8a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-09-17 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct aligned_storage<1, alignment_of<test_type>::value>; + template struct aligned_storage<2>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc new file mode 100644 index 000000000..1399a11a7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// 2007-09-17 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +struct MSAlignType { } __attribute__((__aligned__)); + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::aligned_storage; + using std::alignment_of; + using namespace __gnu_test; + + const std::size_t align_c = alignment_of<char>::value; + VERIFY( (sizeof(aligned_storage<4, align_c>::type) >= 4) ); + VERIFY( (__alignof__(aligned_storage<4, align_c>::type) == align_c) ); + + const std::size_t align_s = alignment_of<short>::value; + VERIFY( (sizeof(aligned_storage<1, align_s>::type) >= 1) ); + VERIFY( (__alignof__(aligned_storage<1, align_s>::type) == align_s) ); + + const std::size_t align_i = alignment_of<int>::value; + VERIFY( (sizeof(aligned_storage<7, align_i>::type) >= 7) ); + VERIFY( (__alignof__(aligned_storage<7, align_i>::type) == align_i) ); + + const std::size_t align_d = alignment_of<double>::value; + VERIFY( (sizeof(aligned_storage<2, align_d>::type) >= 2) ); + VERIFY( (__alignof__(aligned_storage<2, align_d>::type) == align_d) ); + + const std::size_t align_ai = alignment_of<int[4]>::value; + VERIFY( (sizeof(aligned_storage<20, align_ai>::type) >= 20) ); + VERIFY( (__alignof__(aligned_storage<20, align_ai>::type) == align_ai) ); + + const std::size_t align_ct = alignment_of<ClassType>::value; + VERIFY( (sizeof(aligned_storage<11, align_ct>::type) >= 11) ); + VERIFY( (__alignof__(aligned_storage<11, align_ct>::type) == align_ct) ); + + const std::size_t align_msa = alignment_of<MSAlignType>::value; + VERIFY( (sizeof(aligned_storage<5>::type) >= 5) ); + VERIFY( (__alignof__(aligned_storage<5>::type) == align_msa) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/1.cc new file mode 100644 index 000000000..0e1024745 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/1.cc @@ -0,0 +1,65 @@ +// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2004, 2005, 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/>. + +// 20.4.1.1 allocator members + +#include <memory> +#include <stdexcept> +#include <cstdlib> +#include <testsuite_hooks.h> + +struct gnu { }; + +bool check_new = false; +bool check_delete = false; + +void* +operator new(std::size_t n) throw(std::bad_alloc) +{ + check_new = true; + return std::malloc(n); +} + +void operator delete(void *v) throw() +{ + check_delete = true; + return std::free(v); +} + +void test01() +{ + bool test __attribute__((unused)) = true; + std::allocator<gnu> obj; + + // NB: These should work for various size allocation and + // deallocations. Currently, they only work as expected for sizes > + // _MAX_BYTES as defined in stl_alloc.h, which happes to be 128. + gnu* pobj = obj.allocate(256); + VERIFY( check_new ); + + obj.deallocate(pobj, 256); + VERIFY( check_delete ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/10378.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/10378.cc new file mode 100644 index 000000000..f8a7f1ad3 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/10378.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2003, 2004, 2005, 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/>. + +// 20.1.5 allocator requirements / 20.4.1.1 allocator members + +#include <list> +#include <cstdlib> +#include <testsuite_hooks.h> + +class Bob +{ +public: + static void* operator new(size_t sz) + { return std::malloc(sz); } +}; + +// libstdc++/10378 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + list<Bob> uniset; + uniset.push_back(Bob()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/14176.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/14176.cc new file mode 100644 index 000000000..c7442509d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/14176.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2004, 2005, 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/>. + +// 20.4.1.1 allocator members + +#include <memory> +#include <testsuite_hooks.h> + +// libstdc++/14176 +void test02() +{ + unsigned int len = 0; + std::allocator<int> a; + int* p = a.allocate(len); + a.deallocate(p, len); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/33807.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/33807.cc new file mode 100644 index 000000000..637bfcbae --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/33807.cc @@ -0,0 +1,32 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <list> + +// libstdc++/33807 +template <class T> +bool operator != (const T& x, const T& y) { return !(x == y); } + +struct foo { }; + +void fnx() +{ + std::list<foo> l1, l2; + l1 = l2; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/8230.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/8230.cc new file mode 100644 index 000000000..e71f51d21 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/8230.cc @@ -0,0 +1,53 @@ +// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2004, 2005, 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/>. + +// 20.4.1.1 allocator members + +#include <memory> +#include <stdexcept> +#include <testsuite_hooks.h> + +// libstdc++/8230 +void test02() +{ + bool test __attribute__((unused)) = true; + try + { + std::allocator<int> alloc; + const std::allocator<int>::size_type n = alloc.max_size(); + int* p = alloc.allocate(n + 1); + p[n] = 2002; + } + catch(const std::bad_alloc& e) + { + // Allowed. + test = true; + } + catch(...) + { + test = false; + } + VERIFY( test ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..5ca0be4ab --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <memory> + +template class std::allocator<int>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc new file mode 100644 index 000000000..f5246482f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc @@ -0,0 +1,94 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.4.5.1 auto_ptr constructors [lib.auto.ptr.cons] + +// Construction from pointer +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::auto_ptr<A> A_from_A(new A); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::auto_ptr<A> A_from_B(new B); + VERIFY( A_from_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc new file mode 100644 index 000000000..0ae57f97e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// Construction from std::auto_ptr +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<B> B_from_B(new B); + + std::auto_ptr<A> A_from_ptr_A(A_from_A); + std::auto_ptr<A> A_from_ptr_B(B_from_B); + VERIFY( A_from_A.get() == 0 ); + VERIFY( B_from_B.get() == 0 ); + VERIFY( A_from_ptr_A.get() != 0 ); + VERIFY( A_from_ptr_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc new file mode 100644 index 000000000..78fd5aaf6 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// Assignment from std::auto_ptr +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_from_ptr_A; + std::auto_ptr<A> A_from_ptr_B; + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<B> B_from_B(new B); + + A_from_ptr_A = A_from_A; + A_from_ptr_B = B_from_B; + VERIFY( A_from_A.get() == 0 ); + VERIFY( B_from_B.get() == 0 ); + VERIFY( A_from_ptr_A.get() != 0 ); + VERIFY( A_from_ptr_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc new file mode 100644 index 000000000..be034c00c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr<Derived> +conversiontest08() { return std::auto_ptr<Derived>(new Derived); } + +void +test08() +{ + std::auto_ptr<Base> ptr; + ptr = conversiontest08(); +} + + +int +main() +{ + test08(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc new file mode 100644 index 000000000..a623a87b5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// Destruction +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + {/*lifetine scope*/ + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<A> A_from_B(new B); + std::auto_ptr<B> B_from_B(new B); + }/*destructors called here*/ + + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 3 ); + VERIFY( B::ctor_count == 2 ); + VERIFY( B::dtor_count == 2 ); + + return 0; +} + +int +main() +{ + test04(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc new file mode 100644 index 000000000..2f61520e2 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// Class member construction/destruction +template <typename T> +class pimpl +{ +public: + pimpl() : p_impl(new T) {} +private: + std::auto_ptr<T> p_impl; +}; + +int +test05() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + pimpl<A>(); + pimpl<B>(); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); + return 0; +} + +int +main() +{ + test05(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc new file mode 100644 index 000000000..88c2405f2 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.4.5.2 auto_ptr members [lib.auto.ptr.members] + +// Member access +int +test06() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<A> A_from_A_ptr(A_from_A.release()); + VERIFY( A_from_A.get() == 0 ); + VERIFY( A_from_A_ptr.get() != 0 ); + VERIFY( A_from_A_ptr->ctor_count == 1 ); + VERIFY( (*A_from_A_ptr).dtor_count == 0 ); + + A* A_ptr = A_from_A_ptr.get(); + + A_from_A_ptr.reset(A_ptr); + VERIFY( A_from_A_ptr.get() == A_ptr ); + VERIFY( A_from_A_ptr->ctor_count == 1 ); + VERIFY( (*A_from_A_ptr).dtor_count == 0 ); + + A_from_A_ptr.reset(new A); + VERIFY( A_from_A_ptr.get() != A_ptr ); + VERIFY( A_from_A_ptr->ctor_count == 2 ); + VERIFY( (*A_from_A_ptr).dtor_count == 1 ); + return 0; +} + +int +main() +{ + test06(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc new file mode 100644 index 000000000..cf7ea89bf --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 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.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.4.5.3 auto_ptr conversions [lib.auto.ptr.conv] + +// Parameters and return values +template <typename T> +static std::auto_ptr<T> source() +{ + return std::auto_ptr<T>(new T); +} + +template <typename T> +static void drain(std::auto_ptr<T>) +{} + +int +test07() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + drain(source<A>()); + // The resolution of core issue 84, now a DR, breaks this call. + // drain<A>(source<B>()); + drain(source<B>()); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); + return 0; +} + +int +main() +{ + test07(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc new file mode 100644 index 000000000..b4b9eb910 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc @@ -0,0 +1,50 @@ +// { dg-do compile } + +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.4.5 Template class auto_ptr negative tests [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +// via Jack Reeves <jack_reeves@hispeed.ch> +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr<Derived> +foo() { return std::auto_ptr<Derived>(new Derived); } + +int +test01() +{ + std::auto_ptr<Base> ptr2; + ptr2 = new Base; // { dg-error "no match" } + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-error "candidates" "" { target *-*-* } 134 } +// { dg-error "::auto_ptr" "" { target *-*-* } 262 } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..32b526bf3 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <memory> + +template class std::auto_ptr<int>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc new file mode 100644 index 000000000..8ff6d981b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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 <functional> +#include <testsuite_api.h> + +int main() +{ + typedef std::bad_function_call test_type; + __gnu_test::diamond_derivation<test_type, true>::test(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/clocks/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/clocks/1.cc new file mode 100644 index 000000000..e808f45f7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/clocks/1.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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); + + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6d5ef3066 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef int test_type1; + typedef int& test_type2; + typedef double test_type3; + typedef float test_type4; + + template struct common_type<test_type1>; + template struct common_type<test_type1, test_type2>; + template struct common_type<test_type1, test_type2, test_type3>; + template struct common_type<test_type1, test_type2, test_type3, test_type4>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc new file mode 100644 index 000000000..94469d974 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc @@ -0,0 +1,117 @@ +// { dg-options "-std=gnu++0x" } +// +// 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 <type_traits> +#include <testsuite_hooks.h> + +#define JOIN( X, Y ) DO_JOIN( X, Y ) +#define DO_JOIN( X, Y ) DO_JOIN2(X,Y) +#define DO_JOIN2( X, Y ) X##Y + +#define COMMON_TYPE_TEST_1(type1, uid) \ + typedef common_type<type1>::type JOIN(test_t,uid); \ + VERIFY( (is_same<JOIN(test_t,uid), JOIN(test_t,uid)>::value) ); \ + typedef common_type<const type1>::type JOIN(test_t,JOIN(uid,c)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,c)), \ + JOIN(test_t,JOIN(uid,c))>::value) ); \ + typedef common_type<volatile type1>::type JOIN(test_t,JOIN(uid,v)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,v)), \ + JOIN(test_t,JOIN(uid,v))>::value) ); \ + typedef common_type<const volatile type1>::type JOIN(test_t,JOIN(uid,cv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,cv)), \ + JOIN(test_t,JOIN(uid,cv))>::value) ); \ + typedef common_type<type1 &>::type JOIN(test_t,JOIN(uid,l)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,l)), \ + JOIN(test_t,JOIN(uid,l))>::value) ); \ + typedef common_type<const type1 &>::type JOIN(test_t,JOIN(uid,lc)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,lc)), \ + JOIN(test_t,JOIN(uid,lc))>::value) ); \ + typedef common_type<volatile type1 &>::type JOIN(test_t,JOIN(uid,lv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,lv)), \ + JOIN(test_t,JOIN(uid,lv))>::value) ); \ + typedef common_type<const volatile type1 &>::type JOIN(test_t,JOIN(uid,lcv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,lcv)), \ + JOIN(test_t,JOIN(uid,lcv))>::value) ); \ + typedef common_type<type1 &&>::type JOIN(test_t,JOIN(uid,r)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,r)), \ + JOIN(test_t,JOIN(uid,r))>::value) ); \ + typedef common_type<const type1 &&>::type JOIN(test_t,JOIN(uid,rc)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,rc)), \ + JOIN(test_t,JOIN(uid,rc))>::value) ); \ + typedef common_type<volatile type1 &&>::type JOIN(test_t,JOIN(uid,rv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,rv)), \ + JOIN(test_t,JOIN(uid,rv))>::value) ); \ + typedef common_type<const volatile type1 &&>::type JOIN(test_t,JOIN(uid,rcv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,rcv)), \ + JOIN(test_t,JOIN(uid,rcv))>::value) ) + +struct A { }; +struct B : A { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::common_type; + using std::is_same; + + // Positive tests. + COMMON_TYPE_TEST_1(int, 1); + COMMON_TYPE_TEST_1(double, 2); + COMMON_TYPE_TEST_1(A, 3); + COMMON_TYPE_TEST_1(B, 4); +} + +#define COMMON_TYPE_TEST_2_IMPL(type1, type2, type3, uid) \ + typedef common_type<type1, type2>::type JOIN(JOIN(test, uid),_t1); \ + typedef common_type<type2, type1>::type JOIN(JOIN(test, uid),_t2); \ + VERIFY( (is_same<JOIN(JOIN(test, uid),_t1), type3>::value) ); \ + VERIFY( (is_same<JOIN(JOIN(test, uid),_t2), type3>::value) ) + +#define NO_CV + +#define COMMON_TYPE_TEST_2(cv_qual, type1, type2, type3, uid) \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1 &, type2, type3, JOIN(uid,l)); \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1 &&, type2, type3, JOIN(uid,r)) + +#define COMMON_TYPE_TEST_ALL_2(type1, type2, type3, uid) \ + COMMON_TYPE_TEST_2(NO_CV, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(const, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(volatile, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(const volatile, type1, type2, type3, uid) + +void test02() +{ + bool test __attribute__((unused)) = true; + using std::common_type; + using std::is_same; + + COMMON_TYPE_TEST_ALL_2(int, int, int, 1); + COMMON_TYPE_TEST_ALL_2(int, double, double, 2); + COMMON_TYPE_TEST_2(NO_CV, A, A, A, 3); + COMMON_TYPE_TEST_2(const, A, A, const A, 4); + COMMON_TYPE_TEST_2(NO_CV, B, A, A, 5); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..854f46d6f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct conditional<true, test_type, test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc new file mode 100644 index 000000000..c1b145d80 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::conditional; + + typedef conditional<true, char, int>::type test1_type; + VERIFY( (std::is_same<test1_type, char>::value) ); + + typedef conditional<false, char, int>::type test2_type; + VERIFY( (std::is_same<test2_type, int>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6433d945b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct decay<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc new file mode 100644 index 000000000..9a67ab47d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <cstdlib> +#include <type_traits> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::decay; + using std::is_same; + + // Positive tests. + typedef decay<bool>::type test1_type; + VERIFY( (is_same<test1_type, bool>::value) ); + + // NB: DR 705. + typedef decay<const int>::type test2_type; + VERIFY( (is_same<test2_type, int>::value) ); + + typedef decay<int[4]>::type test3_type; + VERIFY( (is_same<test3_type, std::remove_extent<int[4]>::type*>::value) ); + + typedef void (fn_type) (); + typedef decay<fn_type>::type test4_type; + VERIFY( (is_same<test4_type, std::add_pointer<fn_type>::type>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc new file mode 100644 index 000000000..fb955abf1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.3 Class template duration [time.duration] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (unary member ops) +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(3); + duration<int> d1 = -d0; + VERIFY(d0.count() == 3); + VERIFY(d1.count() == -3); + + duration<int> d2 = (+d0); + VERIFY(d2.count() == 3); + + duration<int> d3(++d2); + VERIFY(d2.count() == 4); + VERIFY(d3.count() == 4); + + duration<int> d4(d3++); + VERIFY(d3.count() == 5); + VERIFY(d4.count() == 4); + + duration<int> d5(--d4); + VERIFY(d4.count() == 3); + VERIFY(d5.count() == 3); + + duration<int> d6(d5--); + VERIFY(d5.count() == 2); + VERIFY(d6.count() == 3); +} + +// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (binary member ops) +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d7(3); + duration<int> d8(9); + d7 += d8; + VERIFY(d7.count() == 12); + VERIFY(d8.count() == 9); + + duration<int> d9(3); + duration<int> d10(9); + d9 -= d10; + VERIFY(d9.count() == -6); + VERIFY(d10.count() == 9); + + duration<int> d11(9); + int i = 3; + d11 *= i; + VERIFY(d11.count() == 27); + + duration<int> d12(12); + d12 /= i; + VERIFY(d12.count() == 4); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc new file mode 100644 index 000000000..3940d6a67 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.3 Class template duration [time.duration] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.3.5 duration non-member arithmetic [time.duration.nonmember] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(12); + duration<int> d1(3); + int i = 3; + + duration<int> d2 = d0 + d1; + VERIFY(d2.count() == 15); + + duration<int> d3 = d0 - d1; + VERIFY(d3.count() == 9); + + duration<int> d4 = d0 * i; + VERIFY(d4.count() == 36); + + duration<int> d5 = i * d0; + VERIFY(d5.count() == 36); + + duration<int> d6 = d0 / i; + VERIFY(d6.count() == 4); + + int j = d0 / d1; + VERIFY(j == 4); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/comparisons/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/comparisons/1.cc new file mode 100644 index 000000000..35151f2ad --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/comparisons/1.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.3 Class template duration [time.duration] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.3.6 duration comparisons [time.duration.comparisons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(12); + duration<int> d1(3); + duration<int> d2(3); + + VERIFY(d1 < d0); + VERIFY(d0 > d1); + + VERIFY(d0 != d1); + VERIFY(d1 == d2); + + VERIFY(d1 <= d2); + VERIFY(d1 >= d2); + + VERIFY(d1 <= d0); + VERIFY(d0 >= d1); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/1.cc new file mode 100644 index 000000000..2cd22a4a7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/1.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.3 Class template duration [time.duration] + +#include <chrono> +#include <type_traits> +#include <testsuite_hooks.h> + +template<typename T> +struct type_emulator +{ + type_emulator() + : i(T(0)) { } + + type_emulator(T j) + : i(j) { } + + type_emulator(const type_emulator& e) + : i(e.i) { } + + type_emulator& + operator*=(type_emulator a) + { + i *= a.i; + return *this; + } + + type_emulator& + operator+=(type_emulator a) + { + i += a.i; + return *this; + } + + operator T () + { return i; } + + T i; +}; + +template<typename T> +bool +operator==(type_emulator<T> a, type_emulator<T> b) +{ return a.i == b.i; } + +template<typename T> +bool +operator<(type_emulator<T> a, type_emulator<T> b) +{ return a.i < b.i; } + +template<typename T> +type_emulator<T> +operator+(type_emulator<T> a, type_emulator<T> b) +{ return a += b; } + +template<typename T> +type_emulator<T> +operator*(type_emulator<T> a, type_emulator<T> b) +{ return a *= b; } + +namespace std +{ + template<typename T, typename U> + struct common_type<type_emulator<T>, U> + { typedef typename common_type<T,U>::type type; }; + + template<typename T, typename U> + struct common_type<U, type_emulator<T>> + { typedef typename common_type<U,T>::type type; }; + + template<typename T, typename U> + struct common_type<type_emulator<T>, type_emulator<U>> + { typedef typename common_type<T,U>::type type; }; + + namespace chrono + { + template<typename T> + struct treat_as_floating_point<type_emulator<T>> + : is_floating_point<T> + { }; + } +} + +typedef type_emulator<int> int_emulator; +typedef type_emulator<double> dbl_emulator; + +// 20.8.3.1 duration constructors [time.duration.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using std::chrono::duration; + + int r = 3; + duration<int> d1(r); + VERIFY(d1.count() == static_cast<duration<int>::rep>(r)); + + double s = 8.0; + duration<double> d2(s); + VERIFY(d2.count() == static_cast<duration<double>::rep>(s)); + + int_emulator ie(3); + duration<int_emulator> d3(ie); + VERIFY(d3.count() == static_cast<duration<int_emulator>::rep>(ie)); + + dbl_emulator de(4.0); + duration<dbl_emulator> d4(de); + VERIFY(d4.count() == static_cast<duration<dbl_emulator>::rep>(de)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc new file mode 100644 index 000000000..40d821909 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.3.1 duration constructors [time.duration.cons] + +#include <chrono> + +void +test01() +{ + std::chrono::duration<int> d1(1.0); +} + +void +test02() +{ + using namespace std::chrono; + + duration<int, std::micro> d2(8); + duration<int, std::milli> d2_copy(d2); +} + +// { dg-error "instantiated from here" "" { target *-*-* } 29 } +// { dg-error "instantiated from here" "" { target *-*-* } 38 } +// { dg-error "not exactly representable" "" { target *-*-* } 227 } +// { dg-error "integral duration with floating point" "" { target *-*-* } 217 } +// { dg-excess-errors "In instantiation of" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/2.cc new file mode 100644 index 000000000..820d76401 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/cons/2.cc @@ -0,0 +1,119 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.3 Class template duration [time.duration] + +#include <chrono> +#include <type_traits> +#include <testsuite_hooks.h> + +template<typename T> +struct type_emulator +{ + type_emulator() : i(T(0)) { } + type_emulator(T j) : i(j) { } + type_emulator(const type_emulator& e) : i(e.i) { } + + type_emulator& operator*=(type_emulator a) + { i *= a.i; return *this; } + + type_emulator& operator+=(type_emulator a) + { i += a.i; return *this; } + + operator T () { return i; } + T i; +}; + +template<typename T> +bool operator==(type_emulator<T> a, type_emulator<T> b) +{ return a.i == b.i; } + +template<typename T> +bool operator<(type_emulator<T> a, type_emulator<T> b) +{ return a.i < b.i; } + +template<typename T> +type_emulator<T> operator+(type_emulator<T> a, type_emulator<T> b) +{ return a += b; } + +template<typename T> +type_emulator<T> operator*(type_emulator<T> a, type_emulator<T> b) +{ return a *= b; } + +namespace std +{ + template<typename T, typename U> + struct common_type<type_emulator<T>, U> + { typedef typename common_type<T,U>::type type; }; + + template<typename T, typename U> + struct common_type<U, type_emulator<T>> + { typedef typename common_type<U,T>::type type; }; + + template<typename T, typename U> + struct common_type<type_emulator<T>, type_emulator<U>> + { typedef typename common_type<T,U>::type type; }; + + namespace chrono + { + template<typename T> + struct treat_as_floating_point<type_emulator<T>> + : is_floating_point<T> + { }; + } +} + +typedef type_emulator<int> int_emulator; +typedef type_emulator<double> dbl_emulator; + +// 20.8.3.1 duration constructors [time.duration.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(3); + duration<int> d0_copy(d0); + VERIFY(d0_copy.count() == d0.count()); + + duration<int, std::milli> d1(5); + duration<int, std::micro> d1_copy(d1); + VERIFY(d1.count() * 1000 == d1_copy.count()); + + duration<double, std::micro> d2(8.0); + duration<double, std::milli> d2_copy(d2); + VERIFY(d2.count() == d2_copy.count() * 1000.0); + + duration<int_emulator, std::milli> d3(5); + duration<int_emulator, std::micro> d3_copy(d3); + VERIFY(d3.count() * 1000 == d3_copy.count()); + + duration<dbl_emulator, std::micro> d4(5.0); + duration<dbl_emulator, std::milli> d4_copy(d4); + VERIFY(d4.count() == d4_copy.count() * dbl_emulator(1000.0)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..792d15cb9 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> +#include <chrono> + +template class std::chrono::duration<int>; +template class std::chrono::duration<float, std::ratio<2,3>>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc new file mode 100644 index 000000000..e8b6d33a1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles <chris.fairles@gmail.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 <chrono> + +void test01() +{ + // Check if rep is a duration type + typedef std::chrono::duration<int> rep_type; + typedef std::chrono::duration<rep_type> test_type; + test_type d; +} + +// { dg-error "rep cannot be a duration" "" { target *-*-* } 202 } +// { dg-error "instantiated from here" "" { target *-*-* } 31 } +// { dg-excess-errors "In instantiation of" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc new file mode 100644 index 000000000..910818367 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles <chris.fairles@gmail.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 <chrono> + +void test01() +{ + // Check if period is a ratio + typedef int rep_type; + typedef int period_type; + typedef std::chrono::duration<rep_type, period_type> test_type; + test_type d; +} + +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 203 } +// { dg-error "instantiated from here" "" { target *-*-* } 32 } +// { dg-excess-errors "In instantiation of" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc new file mode 100644 index 000000000..540d72dde --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles <chris.fairles@gmail.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 <ratio> +#include <chrono> + +void test01() +{ + // Check if period is positive + typedef int rep_type; + typedef std::ratio<-1> period_type; + typedef std::chrono::duration<rep_type, period_type> test_type; + test_type d; +} + +// { dg-error "period must be positive" "" { target *-*-* } 205 } +// { dg-error "instantiated from here" "" { target *-*-* } 33 } +// { dg-excess-errors "In instantiation of" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..802a49984 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct enable_if<true>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc new file mode 100644 index 000000000..f17eebadd --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Positive tests. + typedef enable_if<true, int>::type test1_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc new file mode 100644 index 000000000..6ab1fef33 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Negative tests. + typedef enable_if<false, int>::type test2_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 32 } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..9a18a507b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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/>. + +#include <memory> + +template class std::enable_shared_from_this<int>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/1.cc new file mode 100644 index 000000000..7d40416ff --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/1.cc @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <memory> +#include <utility> + +template<class T, class A1, class A2> + std::shared_ptr<T> + factory(A1&& a1, A2&& a2) + { + return std::shared_ptr<T>(new T(std::forward<A1>(a1), + std::forward<A2>(a2))); + } + +struct A +{ + A(int&, const double&); +}; + +void g() +{ + int i = 2; + std::shared_ptr<A> sp1 = factory<A>(i, 1.414); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/1_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/1_neg.cc new file mode 100644 index 000000000..6c007bee2 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/1_neg.cc @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <memory> +#include <utility> + +template<class T, class A1, class A2> + std::shared_ptr<T> + factory(A1&& a1, A2&& a2) + { + return std::shared_ptr<T>(new T(std::forward<A1>(a1), + std::forward<A2>(a2))); // { dg-error "no matching function" } + } + +struct A +{ + A(int&, const double&); +}; + +void g() +{ + std::shared_ptr<A> sp1 = factory<A>(2, 1.414); // { dg-error "instantiated from here" } +} + +// { dg-excess-errors "" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..8b14da23a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing utility with NO OTHER INCLUDES. + +#include <utility> + +namespace std +{ + typedef short test_type; + template test_type&& forward(std::identity<test_type>::type&&); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc new file mode 100644 index 000000000..bbca92716 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2005, 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/>. + +// 20.3.6 Binders + +// { dg-do compile } + +#include <functional> +using namespace std; + +struct s +{ + void f_void_int_const(int) const {} + void f_void_int(int) {} + int f_int_int_const(int) const { return 1; } + int f_int_int(int) {return 1; } + void f_void_void_const() const {} + void f_void_void() {} + int f_int_void_const() const { return 1; } + int f_int_void() { return 1; } +}; + +void test01(s& a) +{ + mem_fun_t<void, s> p1(&s::f_void_void); + mem_fun_t<int, s> p2(&s::f_int_void); + p1(&a); + p2(&a); + mem_fun1_t<void, s, int> q1(&s::f_void_int); + mem_fun1_t<int, s, int> q2(&s::f_int_int); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void))(&a); + (mem_fun(&s::f_void_int))(&a,0); + (mem_fun(&s::f_int_void))(&a); + (mem_fun(&s::f_int_int))(&a,0); + + mem_fun_ref_t<void, s> ref1(&s::f_void_void); + mem_fun_ref_t<int, s> ref2(&s::f_int_void); + + ref1(a); + ref2(a); + + mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int); + mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void))(a); + (mem_fun_ref(&s::f_void_int))(a, 0); + (mem_fun_ref(&s::f_int_void))(a); + (mem_fun_ref(&s::f_int_int))(a, 0); +} + +void test02(const s& a) +{ + const_mem_fun_t<void, s> p1(&s::f_void_void_const); + const_mem_fun_t<int, s> p2(&s::f_int_void_const); + p1(&a); + p2(&a); + const_mem_fun1_t<void, s, int> q1(&s::f_void_int_const); + const_mem_fun1_t<int, s, int> q2(&s::f_int_int_const); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void_const))(&a); + (mem_fun(&s::f_void_int_const))(&a, 0); + (mem_fun(&s::f_int_void_const))(&a); + (mem_fun(&s::f_int_int_const))(&a, 0); + + const_mem_fun_ref_t<void, s> ref1(&s::f_void_void_const); + const_mem_fun_ref_t<int, s> ref2(&s::f_int_void_const); + + ref1(a); + ref2(a); + + const_mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int_const); + const_mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int_const); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void_const))(a); + (mem_fun_ref(&s::f_void_int_const))(a, 0); + (mem_fun_ref(&s::f_int_void_const))(a); + (mem_fun_ref(&s::f_int_int_const))(a, 0); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc new file mode 100644 index 000000000..229e56a4d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc @@ -0,0 +1,49 @@ +// 2001-06-11 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2003, 2004, 2005, 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/>. + +// 20.3.6 Binders + +#include <vector> +#include <algorithm> // for_each +#include <functional> + +class Elem +{ +public: + void print(int) const { } + void modify(int) { } +}; + +// libstdc++/3113 +void test01() +{ + std::vector<Elem> coll(2); + // OK + std::for_each(coll.begin(), coll.end(), + std::bind2nd(std::mem_fun_ref(&Elem::print), 42)); + // OK + std::for_each(coll.begin(), coll.end(), + std::bind2nd(std::mem_fun_ref(&Elem::modify), 42)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc new file mode 100644 index 000000000..fbc7c63c1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc @@ -0,0 +1,52 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 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/>. + +// 20.3.3 Comparisons + +#include <functional> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator!=(const gnu_obj& rhs) const { return i != rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator!=(const gnu_t& rhs) const { return b != rhs.b; } + bool operator<(const gnu_t& rhs) const { return b == rhs.b; } + }; + +template struct std::not_equal_to<void*>; +template struct std::not_equal_to<gnu_obj>; +template struct std::not_equal_to<gnu_t<long> >; + +int main() +{ + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc new file mode 100644 index 000000000..d16542d15 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc @@ -0,0 +1,41 @@ +// 2007-08-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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 <functional> +#include <testsuite_hooks.cc> + +// DR 660. Missing Bitwise Operations. +void test01() +{ + bool test __attribute__((unused)) = true; + + for (int i1 = 0; i1 < 1000; ++i1) + for (int i2 = 0; i2 < 1000; ++i2) + { + VERIFY( std::bit_and<int>()(i1, i2) == (i1 & i2) ); + VERIFY( std::bit_or<int>()(i1, i2) == (i1 | i2) ); + VERIFY( std::bit_xor<int>()(i1, i2) == (i1 ^ i2) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7c8445150 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct has_nothrow_copy_constructor<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..5c40837aa --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2007, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_copy_constructor<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc new file mode 100644 index 000000000..963c7bd57 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2005, 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_copy_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category<has_nothrow_copy_constructor, int>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, float>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, EnumType>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int*>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int(*)(int)>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int (ClassType::*)>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int (ClassType::*) (int)>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int[2]>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, float[][3]>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, EnumType[2][3][4]>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int*[3]>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int(*[][2])(int)>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, int (ClassType::*[2][3])>(true)) ); + VERIFY( (test_category<has_nothrow_copy_constructor, + int (ClassType::*[][2][3]) (int)>(true)) ); + + // Negative tests. + VERIFY( (test_category<has_nothrow_copy_constructor, void>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..dec9b965e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct has_nothrow_default_constructor<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..709fff331 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2007, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_default_constructor<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc new file mode 100644 index 000000000..01548211c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2005, 2006, 2007, 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/>. + +// 4.5.3 Type properties + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_default_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category<has_nothrow_default_constructor, int>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, float>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, EnumType>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, int*>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, int(*)(int)>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, int (ClassType::*)>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, + int (ClassType::*) (int)>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, int[2]>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, float[][3]>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, EnumType[2][3][4]>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, int*[3]>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, int(*[][2])(int)>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, + int (ClassType::*[2][3])>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, + int (ClassType::*[][2][3]) (int)>(true)) ); + VERIFY( (test_category<has_nothrow_default_constructor, ClassType>(true)) ); + + // Negative tests. + VERIFY( (test_category<has_nothrow_default_constructor, void>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6377f60a8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct has_trivial_copy_constructor<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..4b0013f7f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2007, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_copy_constructor<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc new file mode 100644 index 000000000..4f6e287b5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2005, 2007, 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/>. + +// 4.5.3 Type properties + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_copy_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category<has_trivial_copy_constructor, int>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, float>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, EnumType>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int*>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int(*)(int)>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int (ClassType::*)>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int (ClassType::*) (int)>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int[2]>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, float[][3]>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, EnumType[2][3][4]>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int*[3]>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int(*[][2])(int)>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, int (ClassType::*[2][3])>(true)) ); + VERIFY( (test_category<has_trivial_copy_constructor, + int (ClassType::*[][2][3]) (int)>(true)) ); + + // Negative tests. + VERIFY( (test_category<has_trivial_copy_constructor, void>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..2d98181d9 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct has_trivial_default_constructor<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..40f38c34a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2007, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_default_constructor<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc new file mode 100644 index 000000000..397149406 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004, 2005, 2006, 2007, 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/>. + +// 4.5.3 Type properties + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_default_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category<has_trivial_default_constructor, int>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, float>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, EnumType>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, int*>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, int(*)(int)>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, int (ClassType::*)>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, + int (ClassType::*) (int)>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, int[2]>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, float[][3]>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, EnumType[2][3][4]>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, int*[3]>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, int(*[][2])(int)>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, + int (ClassType::*[2][3])>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, + int (ClassType::*[][2][3]) (int)>(true)) ); + VERIFY( (test_category<has_trivial_default_constructor, ClassType>(true)) ); + + // Negative tests. + VERIFY( (test_category<has_trivial_default_constructor, void>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc new file mode 100644 index 000000000..af0c54ec4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2007-08-20 <benjamin@redhat.com> +// +// Copyright (C) 2007, 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 <functional> +#include <system_error> +#include <testsuite_hooks.h> + +template<typename T> + void + do_test() + { + bool test __attribute__((unused)) = true; + + typedef T value_type; + typedef std::hash<value_type> hash_type; + using std::size_t; + + value_type v; // default initialized is fine, same value all that matters. + hash_type h1; + size_t r1 = size_t(h1(v)); + + hash_type h2; + size_t r2 = size_t(h2(v)); + + VERIFY( r1 == r2 ); + } + +void test01() +{ + do_test<std::error_code>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..9c71a5fc9 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 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 <functional> +#include <string> +#include <system_error> + +// Verify that we can instantiate hash for every required type. +template class std::hash<bool>; +template class std::hash<char>; +template class std::hash<signed char>; +template class std::hash<unsigned char>; +template class std::hash<char16_t>; +template class std::hash<char32_t>; +template class std::hash<short>; +template class std::hash<int>; +template class std::hash<long>; +template class std::hash<unsigned short>; +template class std::hash<unsigned int>; +template class std::hash<unsigned long>; +template class std::hash<float>; +template class std::hash<double>; +template class std::hash<long double>; +template class std::hash<void*>; +template class std::hash<std::string>; +template class std::hash<std::error_code>; + +#ifdef _GLIBCXX_USE_WCHAR_T +template class std::hash<wchar_t>; +template class std::hash<std::wstring>; +#endif + diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc new file mode 100644 index 000000000..ad25a7f5e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc @@ -0,0 +1,28 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <cstdlib> + +namespace gnu +{ + using std::calloc; + using std::malloc; + using std::free; + using std::realloc; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc new file mode 100644 index 000000000..34bc2b945 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <cstring> + +namespace gnu +{ + using std::memchr; + using std::memcmp; + using std::memcpy; + using std::memmove; + using std::memset; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc new file mode 100644 index 000000000..d85767dd5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <cstring> + +namespace gnu +{ +#ifndef NULL + #error "NULL_must_be_a_macro" +#endif +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc new file mode 100644 index 000000000..306d2547b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <cstring> + +namespace gnu +{ + std::size_t s; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc new file mode 100644 index 000000000..baba33fc8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc @@ -0,0 +1,33 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <ctime> + +namespace gnu +{ + using std::asctime; + using std::clock; + using std::difftime; + using std::localtime; + using std::strftime; + using std::ctime; + using std::gmtime; + using std::mktime; + using std::time; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc new file mode 100644 index 000000000..0633aa2f8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <ctime> + +namespace gnu +{ +#ifndef NULL + #error "NULL_must_be_a_macro" +#endif +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc new file mode 100644 index 000000000..db7bb7ff1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <ctime> + +namespace gnu +{ + std::size_t s; + std::clock_t c; + std::time_t t; + + std::tm t2; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc new file mode 100644 index 000000000..b58314466 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc @@ -0,0 +1,100 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <functional> + +namespace std { + // lib.base, base: + template <class Arg, class Result> struct unary_function; + template <class Arg1, class Arg2, class Result> struct binary_function; + + // lib.arithmetic.operations, arithmetic operations: + template <class T> struct plus; + template <class T> struct minus; + template <class T> struct multiplies; + template <class T> struct divides; + template <class T> struct modulus; + template <class T> struct negate; + + // lib.comparisons, comparisons: + template <class T> struct equal_to; + template <class T> struct not_equal_to; + template <class T> struct greater; + template <class T> struct less; + template <class T> struct greater_equal; + template <class T> struct less_equal; + + // lib.logical.operations, logical operations: + template <class T> struct logical_and; + template <class T> struct logical_or; + template <class T> struct logical_not; + + // lib.negators, negators: + template <class Predicate> struct unary_negate; + template <class Predicate> + unary_negate<Predicate> not1(const Predicate&); + template <class Predicate> struct binary_negate; + template <class Predicate> + binary_negate<Predicate> not2(const Predicate&); + + // lib.binders, binders: + template <class Operation> class binder1st; + template <class Operation, class T> + binder1st<Operation> bind1st(const Operation&, const T&); + template <class Operation> class binder2nd; + template <class Operation, class T> + binder2nd<Operation> bind2nd(const Operation&, const T&); + + // lib.function.pointer.adaptors, adaptors: + template <class Arg, class Result> class pointer_to_unary_function; + template <class Arg, class Result> + pointer_to_unary_function<Arg,Result> ptr_fun(Result (*)(Arg)); + template <class Arg1, class Arg2, class Result> + class pointer_to_binary_function; + template <class Arg1, class Arg2, class Result> + pointer_to_binary_function<Arg1,Arg2,Result> + ptr_fun(Result (*)(Arg1,Arg2)); + + // lib.member.pointer.adaptors, adaptors: + template<class S, class T> class mem_fun_t; + template<class S, class T, class A> class mem_fun1_t; + template<class S, class T> + mem_fun_t<S,T> mem_fun(S (T::*f)()); + template<class S, class T, class A> + mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); + template<class S, class T> class mem_fun_ref_t; + template<class S, class T, class A> class mem_fun1_ref_t; + template<class S, class T> + mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); + template<class S, class T, class A> + mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); + + template <class S, class T> class const_mem_fun_t; + template <class S, class T, class A> class const_mem_fun1_t; + template <class S, class T> + const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); + template <class S, class T, class A> + const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); + template <class S, class T> class const_mem_fun_ref_t; + template <class S, class T, class A> class const_mem_fun1_ref_t; + template <class S, class T> + const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); + template <class S, class T, class A> + const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc new file mode 100644 index 000000000..264542811 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 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 <functional> + +namespace gnu +{ + using std::bad_function_call; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc new file mode 100644 index 000000000..5d2a7a863 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 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 <functional> + +namespace gnu +{ + using namespace std::placeholders; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc new file mode 100644 index 000000000..4d45071e6 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc @@ -0,0 +1,53 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <memory> + +namespace std { + // lib.default.allocator, the default allocator: + template <class T> class allocator; + template <> class allocator<void>; + template <class T, class U> + bool operator==(const allocator<T>&, const allocator<U>&) throw(); + template <class T, class U> + bool operator!=(const allocator<T>&, const allocator<U>&) throw(); + + // lib.storage.iterator, raw storage iterator: + template <class OutputIterator, class T> class raw_storage_iterator; + + // lib.temporary.buffer, temporary buffers: + template <class T> + pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n); + template <class T> + void return_temporary_buffer(T* p); + + // lib.specialized.algorithms, specialized algorithms: + template <class InputIterator, class ForwardIterator> + ForwardIterator + uninitialized_copy(InputIterator first, InputIterator last, + ForwardIterator result); + template <class ForwardIterator, class T> + void uninitialized_fill(ForwardIterator first, ForwardIterator last, + const T& x); + template <class ForwardIterator, class Size, class T> + void uninitialized_fill_n(ForwardIterator first, Size n, const T& x); + + // lib.auto.ptr, pointers: + template<class X> class auto_ptr; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc new file mode 100644 index 000000000..dc50b63bb --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 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 <memory> + +namespace gnu +{ + using std::bad_weak_ptr; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc new file mode 100644 index 000000000..7d83fd9f9 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007, 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 <type_traits> // { dg-excess-errors "In file included from" } + +// { dg-error "upcoming ISO" "" { target *-*-* } 31 } + + + diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc new file mode 100644 index 000000000..0fc1ce295 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 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 <type_traits> + +namespace gnu +{ + using std::true_type; + using std::false_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc new file mode 100644 index 000000000..5ada352ec --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 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 <type_traits> + +namespace gnu +{ + // C++0x changes from TR1. + using std::has_trivial_constructor; + using std::has_nothrow_constructor; + using std::has_trivial_copy; + using std::has_nothrow_copy; +} + +// { dg-error "has not been declared" "" { target *-*-* } 26 } +// { dg-error "has not been declared" "" { target *-*-* } 27 } +// { dg-error "has not been declared" "" { target *-*-* } 28 } +// { dg-error "has not been declared" "" { target *-*-* } 29 } + diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc new file mode 100644 index 000000000..49d7c2ffe --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc @@ -0,0 +1,45 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <utility> + +namespace std { + // lib.operators, operators: + namespace rel_ops { + template<class T> bool operator!=(const T&, const T&); + template<class T> bool operator> (const T&, const T&); + template<class T> bool operator<=(const T&, const T&); + template<class T> bool operator>=(const T&, const T&); + } + + // lib.pairs, pairs: + template <class T1, class T2> struct pair; + template <class T1, class T2> + bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc new file mode 100644 index 000000000..60753a00f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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 <utility> + +namespace gnu +{ + using namespace std::rel_ops; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..691f81b93 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing utility with NO OTHER INCLUDES. + +#include <utility> + +namespace std +{ + typedef short test_type; + template struct decay<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/requirements/typedefs.cc new file mode 100644 index 000000000..c170818d9 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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/>. + +// +// NB: This file is for testing utility with NO OTHER INCLUDES. + +#include <utility> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::identity<int> test_type; + typedef test_type::type type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/value.cc new file mode 100644 index 000000000..80b444bf4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/identity/value.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <utility> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::identity; + using std::is_same; + using namespace __gnu_test; + + VERIFY( (is_same<identity<int>::type, int>::value) ); + VERIFY( (is_same<identity<int&>::type, int&>::value) ); + VERIFY( (is_same<identity<int&&>::type, int&&>::value) ); + VERIFY( (is_same<identity<int*>::type, int*>::value) ); + VERIFY( (is_same<identity<ClassType&&>::type, ClassType&&>::value) ); + VERIFY( (is_same<identity<ClassType>::type, ClassType>::value) ); + VERIFY( (is_same<identity<int(int)>::type, int(int)>::value) ); + VERIFY( (is_same<identity<void>::type, void>::value) ); + VERIFY( (is_same<identity<const void>::type, const void>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..a294d097b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2008-05-20 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_integral<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc new file mode 100644 index 000000000..43bac85ee --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-20 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_integral<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/value.cc new file mode 100644 index 000000000..6b1717b38 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_integral/value.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-20 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_integral; + using namespace __gnu_test; + + VERIFY( (test_category<is_integral, void>(false)) ); + + VERIFY( (test_category<is_integral, char>(true)) ); + VERIFY( (test_category<is_integral, signed char>(true)) ); + VERIFY( (test_category<is_integral, unsigned char>(true)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category<is_integral, wchar_t>(true)) ); +#endif + VERIFY( (test_category<is_integral, char16_t>(true)) ); + VERIFY( (test_category<is_integral, char32_t>(true)) ); + VERIFY( (test_category<is_integral, short>(true)) ); + VERIFY( (test_category<is_integral, unsigned short>(true)) ); + VERIFY( (test_category<is_integral, int>(true)) ); + VERIFY( (test_category<is_integral, unsigned int>(true)) ); + VERIFY( (test_category<is_integral, long>(true)) ); + VERIFY( (test_category<is_integral, unsigned long>(true)) ); + VERIFY( (test_category<is_integral, long long>(true)) ); + VERIFY( (test_category<is_integral, unsigned long long>(true)) ); + + VERIFY( (test_category<is_integral, float>(false)) ); + VERIFY( (test_category<is_integral, double>(false)) ); + VERIFY( (test_category<is_integral, long double>(false)) ); + + // Sanity check. + VERIFY( (test_category<is_integral, ClassType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..09ae91219 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_lvalue_reference<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..348b59936 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_lvalue_reference<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc new file mode 100644 index 000000000..f57713585 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_lvalue_reference; + using namespace __gnu_test; + + VERIFY( (test_category<is_lvalue_reference, int&>(true)) ); + VERIFY( (test_category<is_lvalue_reference, ClassType&>(true)) ); + VERIFY( (test_category<is_lvalue_reference, int(&)(int)>(true)) ); + + // Sanity check. + VERIFY( (test_category<is_lvalue_reference, int&&>(false)) ); + VERIFY( (test_category<is_lvalue_reference, ClassType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..faf66d772 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_reference<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc new file mode 100644 index 000000000..ff572915f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_reference<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/value.cc new file mode 100644 index 000000000..a6782ab9a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_reference/value.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_reference; + using namespace __gnu_test; + + VERIFY( (test_category<is_reference, int&>(true)) ); + VERIFY( (test_category<is_reference, ClassType&>(true)) ); + VERIFY( (test_category<is_reference, int(&)(int)>(true)) ); + VERIFY( (test_category<is_reference, int&&>(true)) ); + VERIFY( (test_category<is_reference, ClassType&&>(true)) ); + VERIFY( (test_category<is_reference, int(&&)(int)>(true)) ); + + // Sanity check. + VERIFY( (test_category<is_reference, ClassType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..336881339 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_rvalue_reference<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..b7523bb8d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_rvalue_reference<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc new file mode 100644 index 000000000..1e83d0514 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_rvalue_reference; + using namespace __gnu_test; + + VERIFY( (test_category<is_rvalue_reference, int&&>(true)) ); + VERIFY( (test_category<is_rvalue_reference, ClassType&&>(true)) ); + VERIFY( (test_category<is_rvalue_reference, int(&&)(int)>(true)) ); + + // Sanity check. + VERIFY( (test_category<is_rvalue_reference, int&>(false)) ); + VERIFY( (test_category<is_rvalue_reference, ClassType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d64ce7e40 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_signed<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc new file mode 100644 index 000000000..6706c60bf --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_signed<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/value.cc new file mode 100644 index 000000000..194e268b6 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_signed/value.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_signed; + using namespace __gnu_test; + + VERIFY( (test_category<is_signed, void>(false)) ); + + VERIFY( (test_category<is_signed, char>(char(-1) < char(0))) ); + VERIFY( (test_category<is_signed, signed char>(true)) ); + VERIFY( (test_category<is_signed, unsigned char>(false)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category<is_signed, wchar_t>(wchar_t(-1) < wchar_t(0))) ); +#endif + VERIFY( (test_category<is_signed, short>(true)) ); + VERIFY( (test_category<is_signed, unsigned short>(false)) ); + VERIFY( (test_category<is_signed, int>(true)) ); + VERIFY( (test_category<is_signed, unsigned int>(false)) ); + VERIFY( (test_category<is_signed, long>(true)) ); + VERIFY( (test_category<is_signed, unsigned long>(false)) ); + VERIFY( (test_category<is_signed, long long>(true)) ); + VERIFY( (test_category<is_signed, unsigned long long>(false)) ); + + VERIFY( (test_category<is_signed, float>(true)) ); + VERIFY( (test_category<is_signed, double>(true)) ); + VERIFY( (test_category<is_signed, long double>(true)) ); + + // Sanity check. + VERIFY( (test_category<is_signed, ClassType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..52b8406e2 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_unsigned<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc new file mode 100644 index 000000000..3538edca7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005, 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_unsigned<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc new file mode 100644 index 000000000..5163cf975 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_unsigned; + using namespace __gnu_test; + + VERIFY( (test_category<is_unsigned, void>(false)) ); + + VERIFY( (test_category<is_unsigned, char>(char(-1) > char(0))) ); + VERIFY( (test_category<is_unsigned, signed char>(false)) ); + VERIFY( (test_category<is_unsigned, unsigned char>(true)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category<is_unsigned, wchar_t>(wchar_t(-1) > wchar_t(0))) ); +#endif + VERIFY( (test_category<is_unsigned, short>(false)) ); + VERIFY( (test_category<is_unsigned, unsigned short>(true)) ); + VERIFY( (test_category<is_unsigned, int>(false)) ); + VERIFY( (test_category<is_unsigned, unsigned int>(true)) ); + VERIFY( (test_category<is_unsigned, long>(false)) ); + VERIFY( (test_category<is_unsigned, unsigned long>(true)) ); + VERIFY( (test_category<is_unsigned, long long>(false)) ); + VERIFY( (test_category<is_unsigned, unsigned long long>(true)) ); + + VERIFY( (test_category<is_unsigned, float>(false)) ); + VERIFY( (test_category<is_unsigned, double>(false)) ); + VERIFY( (test_category<is_unsigned, long double>(false)) ); + + // Sanity check. + VERIFY( (test_category<is_unsigned, ClassType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..77061d5b4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct make_signed<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc new file mode 100644 index 000000000..6c21a1e75 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_signed; + using std::is_same; + using std::is_signed; + + // Positive tests. + typedef make_signed<const int>::type test2_type; + VERIFY( (is_same<test2_type, const int>::value) ); + + typedef make_signed<const unsigned int>::type test21c_type; + VERIFY( (is_same<test21c_type, const signed int>::value) ); + + typedef make_signed<volatile unsigned int>::type test21v_type; + VERIFY( (is_same<test21v_type, volatile signed int>::value) ); + + typedef make_signed<const volatile unsigned int>::type test21cv_type; + VERIFY( (is_same<test21cv_type, const volatile signed int>::value) ); + + typedef make_signed<const char>::type test22_type; + VERIFY( (is_same<test22_type, const signed char>::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_signed<volatile wchar_t>::type test23_type; + VERIFY( (is_same<test23_type, volatile signed wchar_t>::value) ); +#endif + + // Chapter 48, chapter 20. Smallest rank such that new signed type same size. + typedef make_signed<test_enum>::type test25_type; + VERIFY( is_signed<test25_type>::value ); + VERIFY( sizeof(test25_type) == sizeof(test_enum) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc new file mode 100644 index 000000000..cb40b7bff --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" } +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> + +// Ensure that this enum has "short" as its underlying type. +enum test_enum { first_selection = ((unsigned char)-1) + 1 }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_signed; + using std::is_same; + + // Positive tests. + typedef make_signed<const int>::type test2_type; + VERIFY( (is_same<test2_type, const int>::value) ); + + typedef make_signed<const unsigned int>::type test21c_type; + VERIFY( (is_same<test21c_type, const signed int>::value) ); + + typedef make_signed<volatile unsigned int>::type test21v_type; + VERIFY( (is_same<test21v_type, volatile signed int>::value) ); + + typedef make_signed<const volatile unsigned int>::type test21cv_type; + VERIFY( (is_same<test21cv_type, const volatile signed int>::value) ); + + typedef make_signed<const char>::type test22_type; + VERIFY( (is_same<test22_type, const signed char>::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_signed<volatile wchar_t>::type test23_type; + VERIFY( (is_same<test23_type, volatile signed wchar_t>::value) ); +#endif + + typedef make_signed<test_enum>::type test25_type; + VERIFY( (is_same<test25_type, short>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc new file mode 100644 index 000000000..ca7ee97af --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_character.h> + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_signed; + + // Negative tests. + typedef make_signed<bool>::type test1_type; + + typedef make_signed<__gnu_test::pod_uint>::type test2_type; + + typedef make_signed<int[4]>::type test3_type; + + typedef void (fn_type) (); + typedef make_signed<fn_type>::type test4_type; + + typedef make_signed<float>::type test5_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } +// { dg-error "instantiated from here" "" { target *-*-* } 35 } +// { dg-error "instantiated from here" "" { target *-*-* } 37 } +// { dg-error "instantiated from here" "" { target *-*-* } 40 } +// { dg-error "instantiated from here" "" { target *-*-* } 42 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 557 } +// { dg-error "declaration of" "" { target *-*-* } 519 } + +// { dg-excess-errors "At global scope" } +// { dg-excess-errors "In instantiation of" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7821dd7ae --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct make_unsigned<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc new file mode 100644 index 000000000..9d96d5b89 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_unsigned; + using std::is_same; + using std::is_unsigned; + + // Positive tests. + typedef make_unsigned<const unsigned int>::type test2_type; + VERIFY( (is_same<test2_type, const unsigned int>::value) ); + + typedef make_unsigned<const signed int>::type test21c_type; + VERIFY( (is_same<test21c_type, const unsigned int>::value) ); + + typedef make_unsigned<volatile signed int>::type test21v_type; + VERIFY( (is_same<test21v_type, volatile unsigned int>::value) ); + + typedef make_unsigned<const volatile signed int>::type test21cv_type; + VERIFY( (is_same<test21cv_type, const volatile unsigned int>::value) ); + + typedef make_unsigned<const char>::type test22_type; + VERIFY( (is_same<test22_type, const unsigned char>::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_unsigned<volatile wchar_t>::type test23_type; + VERIFY( (is_same<test23_type, volatile wchar_t>::value) ); +#endif + + // Chapter 48, chapter 20. Smallest rank such that new unsigned type + // same size. + typedef make_unsigned<test_enum>::type test25_type; + VERIFY( is_unsigned<test25_type>::value ); + VERIFY( sizeof(test25_type) == sizeof(test_enum) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc new file mode 100644 index 000000000..d71c01282 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" } +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> + +// Ensure that this enum has "short" as its underlying type. +enum test_enum { first_selection = ((unsigned char)-1) + 1 }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_unsigned; + using std::is_same; + + // Positive tests. + typedef make_unsigned<const unsigned int>::type test2_type; + VERIFY( (is_same<test2_type, const unsigned int>::value) ); + + typedef make_unsigned<const signed int>::type test21c_type; + VERIFY( (is_same<test21c_type, const unsigned int>::value) ); + + typedef make_unsigned<volatile signed int>::type test21v_type; + VERIFY( (is_same<test21v_type, volatile unsigned int>::value) ); + + typedef make_unsigned<const volatile signed int>::type test21cv_type; + VERIFY( (is_same<test21cv_type, const volatile unsigned int>::value) ); + + typedef make_unsigned<const char>::type test22_type; + VERIFY( (is_same<test22_type, const unsigned char>::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_unsigned<volatile wchar_t>::type test23_type; + VERIFY( (is_same<test23_type, volatile wchar_t>::value) ); +#endif + + typedef make_unsigned<test_enum>::type test25_type; + VERIFY( (is_same<test25_type, unsigned short>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc new file mode 100644 index 000000000..ac9fef16e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_character.h> + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_unsigned; + + // Negative tests. + typedef make_unsigned<bool>::type test1_type; + + typedef make_unsigned<__gnu_test::pod_uint>::type test2_type; + + typedef make_unsigned<int[4]>::type test3_type; + + typedef void (fn_type) (); + typedef make_unsigned<fn_type>::type test4_type; + + typedef make_unsigned<float>::type test5_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } +// { dg-error "instantiated from here" "" { target *-*-* } 35 } +// { dg-error "instantiated from here" "" { target *-*-* } 37 } +// { dg-error "instantiated from here" "" { target *-*-* } 40 } +// { dg-error "instantiated from here" "" { target *-*-* } 42 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 478 } +// { dg-error "declaration of" "" { target *-*-* } 440 } + +// { dg-excess-errors "At global scope" } +// { dg-excess-errors "In instantiation of" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/move/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/move/1.cc new file mode 100644 index 000000000..bb7b4e601 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/move/1.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <memory> +#include <utility> + +template<class T, class A1> + std::shared_ptr<T> + factory(A1&& a1) + { + return std::shared_ptr<T>(new T(std::forward<A1>(a1))); + } + +struct A +{ + A(); + A(const A&); + A(A&&); +}; + +void g() +{ + A a; + std::shared_ptr<A> sp1 = factory<A>(a); + std::shared_ptr<A> sp2 = factory<A>(std::move(a)); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..53b4e9bb8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing utility with NO OTHER INCLUDES. + +#include <utility> + +namespace std +{ + typedef short test_type; + template std::remove_reference<test_type>::type&& move(test_type&&); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc new file mode 100644 index 000000000..440ac76a7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc @@ -0,0 +1,127 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.13.4 Template class owner_less [util.smartptr.ownerless] + +#include <memory> +#include <algorithm> +#include <testsuite_hooks.h> + +struct A { }; + +struct B { A a[2]; }; + +// 20.8.13.4 Template class owner_less [util.smartptr.ownerless] + +int +test01() +{ + // test empty shared_ptrs compare equivalent + std::owner_less<std::shared_ptr<A>> less; + std::owner_less<std::weak_ptr<A>> wless; + std::shared_ptr<A> p1; + std::shared_ptr<A> p2; + VERIFY( !less(p1, p2) && !less(p2, p1) ); + std::weak_ptr<A> p3; + VERIFY( !less(p1, p3) && !less(p3, p1) ); + VERIFY( !wless(p1, p3) && !wless(p3, p1) ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + std::owner_less<std::shared_ptr<A>> less; + std::owner_less<std::weak_ptr<A>> wless; + + std::shared_ptr<A> empty; + + std::shared_ptr<A> a1(new A); + VERIFY( less(empty, a1) || less(a1, empty) ); + + std::shared_ptr<A> a2(new A); + VERIFY( less(a1, a2) || less(a2, a1) ); + + std::weak_ptr<A> w1(a1); + VERIFY( !less(a1, w1) && !less(w1, a1) ); + + std::weak_ptr<A> w2(a2); + VERIFY( wless(w1, w2) || wless(w2, w1) ); + + a1.reset(); + VERIFY( !less(empty, a1) && !less(a1, empty) ); + VERIFY( less(a1, w1) || less(w1, a1) ); + + a2.reset(); + VERIFY( !less(a2, a1) && !less(a1, a2) ); + + return 0; +} + +// aliasing +int +test03() +{ + std::owner_less<std::shared_ptr<A>> less; + std::owner_less<std::weak_ptr<A>> wless; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a0(b, &b->a[0]); + std::shared_ptr<A> a1(b, &b->a[1]); + // values are different but owners are equivalent: + VERIFY( a0 < a1 && !less(a0, a1) && !less(a1, a0) ); + + std::weak_ptr<A> w0(a0); + std::weak_ptr<A> w1(a1); + VERIFY( !wless(w0, w1) && !wless(w1, w0) ); + VERIFY( !less(a0, w1) && !less(w1, a0) ); + VERIFY( !wless(w0, a1) && !wless(a1, w0) ); + + return 0; +} + +// strict weak ordering +int +test04() +{ + std::owner_less<std::shared_ptr<A>> less; + + std::shared_ptr<A> a[3]; + a[0].reset(new A); + a[1].reset(new A); + a[2].reset(new A); + std::sort(a, a+3, less); + VERIFY( !less(a[0], a[0]) ); + VERIFY( less(a[0], a[1]) && !less(a[1], a[0]) ); + VERIFY( less(a[0], a[1]) && less(a[1], a[2]) && less(a[0], a[2]) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/1.cc new file mode 100644 index 000000000..f5b15f755 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/1.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2004, 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + + +// heterogeneous +void test01() +{ + bool test __attribute__((unused)) = true; + + std::pair<bool, long> p_bl_1(true, 433); + std::pair<bool, long> p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + std::pair<const char*, float> p_sf_1("total enlightenment", 433.00); + std::pair<const char*, float> p_sf_2 = std::make_pair("total enlightenment", + 433.00); + VERIFY( p_sf_1 == p_sf_2 ); + VERIFY( !(p_sf_1 < p_sf_2) ); + + std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5)); + std::pair<const char*, gnu_obj> p_sg_2 = std::make_pair("enlightenment", + gnu_obj(5)); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5)); + std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(gnu_t<long>(false), + gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/2.cc new file mode 100644 index 000000000..0826cdb2f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/2.cc @@ -0,0 +1,59 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2004, 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + +// homogeneous +void test02() +{ + bool test __attribute__((unused)) = true; + + std::pair<bool, bool> p_bb_1(true, false); + std::pair<bool, bool> p_bb_2 = std::make_pair(true, false); + VERIFY( p_bb_1 == p_bb_2 ); + VERIFY( !(p_bb_1 < p_bb_2) ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/3.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/3.cc new file mode 100644 index 000000000..fc19a4acd --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/3.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2004, 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + + +// const +void test03() +{ + bool test __attribute__((unused)) = true; + + const std::pair<bool, long> p_bl_1(true, 433); + const std::pair<bool, long> p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + const std::pair<const char*, float> p_sf_1("total enlightenment", 433.00); + const std::pair<const char*, float> p_sf_2 = + std::make_pair("total enlightenment", 433.00); + VERIFY( p_sf_1 == p_sf_2 ); + VERIFY( !(p_sf_1 < p_sf_2) ); + + const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5)); + const std::pair<const char*, gnu_obj> p_sg_2 = + std::make_pair("enlightenment", gnu_obj(5)); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + const std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5)); + const std::pair<gnu_t<long>, gnu_obj> p_st_2 = + std::make_pair(gnu_t<long>(false), gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/4.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/4.cc new file mode 100644 index 000000000..7431fc1e7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/4.cc @@ -0,0 +1,66 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2004, 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + +// const& +void test04() +{ + bool test __attribute__((unused)) = true; + const gnu_obj& obj1 = gnu_obj(5); + const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", obj1); + const std::pair<const char*, gnu_obj> p_sg_2 = + std::make_pair("enlightenment", obj1); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + const gnu_t<long>& tmpl1 = gnu_t<long>(false); + const std::pair<gnu_t<long>, gnu_obj> p_st_1(tmpl1, obj1); + const std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(tmpl1, obj1); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test04(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/moveable.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/moveable.cc new file mode 100644 index 000000000..9abdd8107 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/moveable.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 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/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on pair, and also vector. If the implementation +// changes this test may begin to fail. + +#include <vector> +#include <utility> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void +test1() +{ + std::pair<int,int> a(1,1),b(2,2); + a=std::move(b); + VERIFY(a.first == 2 && a.second == 2 && b.first == 2 && b.second == 2); + std::pair<int,int> c(std::move(a)); + VERIFY(c.first == 2 && c.second == 2 && a.first == 2 && a.second == 2); +} + +void +test2() +{ + std::vector<int> v,w; + v.push_back(1); + w.push_back(2); + w.push_back(2); + std::pair<int, std::vector<int> > p = make_pair(1,v); + std::pair<int, std::vector<int> > q = make_pair(2,w); + p = std::move(q); + VERIFY(p.first == 2 && q.first == 2 && + p.second.size() == 2 && q.second.size() == 0); + std::pair<int, std::vector<int> > r(std::move(p)); + VERIFY(r.first == 2 && p.first == 2 && + r.second.size() == 2 && p.second.size() == 0); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..262c575cf --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <utility> + +template class std::pair<int, long>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/swap.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/swap.cc new file mode 100644 index 000000000..a76f5f3cb --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/pair/swap.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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 <utility> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef __gnu_test::uneq_allocator<double> ua_type; + ua_type one(1), two(2); + + std::pair<ua_type, int> p1(one, 1), p2(two, 2); + + p1.swap(p2); + VERIFY( p1.first.get_personality() == 2 ); + VERIFY( p1.second == 2 ); + VERIFY( p2.first.get_personality() == 1 ); + VERIFY( p2.second == 1 ); + + swap(p1, p2); + VERIFY( p2.first.get_personality() == 2 ); + VERIFY( p2.second == 2 ); + VERIFY( p1.first.get_personality() == 1 ); + VERIFY( p1.second == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc new file mode 100644 index 000000000..f4354fe96 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc @@ -0,0 +1,81 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,3>>::value == 1 )); + VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,4>>::value == 0 )); + + VERIFY( (std::ratio_not_equal<std::ratio<2,6>, + std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_not_equal<std::ratio<2,6>, + std::ratio<1,4>>::value == 1) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + VERIFY( (std::ratio_less<std::ratio<1,4>, std::ratio<1,3>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<1,3>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<1,4>>::value == 0) ); + VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<-1,3>>::value == 0) ); + + VERIFY( (std::ratio_less_equal<std::ratio<-1,3>, + std::ratio<-1,3>>::value == 1) ); + VERIFY( ( std::ratio_less_equal<std::ratio<1,4>, + std::ratio<1,3>>::value == 1) ); + + VERIFY( (std::ratio_less_equal<std::ratio<1,4>, + std::ratio<-1,3>>::value == 0) ); + VERIFY( (std::ratio_less_equal<std::ratio<1,3>, + std::ratio<-1,3>>::value == 0) ); + + VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<1,4>>::value == 1) ); + VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<-1,3>>::value == 1) ); + + VERIFY( (std::ratio_greater<std::ratio<1,4>, std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_greater<std::ratio<-1,3>, std::ratio<1,3>>::value == 0) ); + + VERIFY( (std::ratio_greater_equal<std::ratio<1,3>, + std::ratio<1,3>>::value == 1) ); + VERIFY( (std::ratio_greater_equal<std::ratio<1,3>, + std::ratio<-1,3>>::value == 1) ); + + VERIFY( (std::ratio_greater_equal<std::ratio<-1,3>, + std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_greater_equal<std::ratio<1,4>, + std::ratio<1,3>>::value == 0) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc new file mode 100644 index 000000000..e741c1435 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> +#include <testsuite_hooks.h> + +static const std::intmax_t M = INTMAX_MAX; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + // No overflow with same denominator + VERIFY( (std::ratio_less<std::ratio<M - 2, M>, + std::ratio<M - 1, M>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<M - 1, M>, + std::ratio<M - 2, M>>::value == 0) ); + + // No overflow if signs differ + VERIFY( (std::ratio_less<std::ratio<-M, M - 1>, + std::ratio<M - 1, M - 2>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<M - 1, M - 2>, + std::ratio<-M, M - 1>>::value == 0) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc new file mode 100644 index 000000000..a3dab54fd --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio<1,3> r0; + std::ratio<2,6> r1; + std::ratio<2,-6> r2; + std::ratio<-2,6> r3; + + VERIFY( r0.num == 1 ); + VERIFY( r0.den == 3 ); + + VERIFY( r1.num == r0.num ); + VERIFY( r1.den == r0.den ); + VERIFY( r2.num == -r0.num ); + VERIFY( r2.den == r0.den ); + VERIFY( r3.num == -r0.num ); + VERIFY( r3.den == r0.den ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc new file mode 100644 index 000000000..03c2c1f58 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc @@ -0,0 +1,54 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> + +void +test01() +{ + std::ratio<INTMAX_MAX, INTMAX_MAX> r1; + std::ratio<-INTMAX_MAX, INTMAX_MAX> r2; +} + +void +test02() +{ + std::ratio<INTMAX_MIN, 1> r1; +} + +void +test03() +{ + std::ratio<1, INTMAX_MIN> r1; +} + +void +test04() +{ + std::ratio<1,0> r1; +} + +// { dg-error "instantiated from here" "" { target *-*-* } 34 } +// { dg-error "instantiated from here" "" { target *-*-* } 40 } +// { dg-error "instantiated from here" "" { target *-*-* } 46 } +// { dg-error "denominator cannot be zero" "" { target *-*-* } 153 } +// { dg-error "out of range" "" { target *-*-* } 154 } +// { dg-excess-errors "In instantiation of" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc new file mode 100644 index 000000000..183269e62 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_add<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == 19 ); + VERIFY( r.den == 24 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + std::ratio_subtract<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == -1 ); + VERIFY( r.den == 24 ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + std::ratio_multiply<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == 5 ); + VERIFY( r.den == 32 ); +} + +void +test04() +{ + bool test __attribute__((unused)) = true; + std::ratio_divide<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == 9 ); + VERIFY( r.den == 10 ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc new file mode 100644 index 000000000..abd2e7556 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> +#include <testsuite_hooks.h> + +typedef std::ratio<1, INTMAX_MAX> one_over_max; +typedef std::ratio<2, INTMAX_MAX> two_over_max; +typedef std::ratio<INTMAX_MAX, 1> max_over_one; +typedef std::ratio<INTMAX_MAX, 2> max_over_two; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_add<one_over_max, one_over_max>::type r1; + + VERIFY( r1.num == two_over_max::num); + VERIFY( r1.den == two_over_max::den); + + std::ratio_add< + std::ratio<INTMAX_MAX / 2, INTMAX_MAX / 2>, + std::ratio<INTMAX_MAX / 2 , INTMAX_MAX / 2 + 1>>::type r2; + + VERIFY( r2.num == INTMAX_MAX ); + VERIFY( r2.den == (INTMAX_MAX / 2) + 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::ratio_subtract<one_over_max, one_over_max>::type r1; + + VERIFY( r1.num == 0); + VERIFY( r1.den == 1); + + std::ratio_subtract< + std::ratio<INTMAX_MAX / 2, INTMAX_MAX / 2>, + std::ratio<INTMAX_MAX / 2 , INTMAX_MAX / 2 + 1>>::type r2; + + VERIFY( r2.num == 1 ); + VERIFY( r2.den == (INTMAX_MAX / 2) + 1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc new file mode 100644 index 000000000..fde9fb9dd --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_multiply< + std::ratio<2, INTMAX_MAX>, + std::ratio<INTMAX_MAX, 2>>::type r1; + + VERIFY( r1.num == 1 ); + VERIFY( r1.den == 1 ); + + std::ratio_multiply< + std::ratio<INTMAX_MAX, 2>, + std::ratio<2 , INTMAX_MAX - 1>>::type r2; + + VERIFY( r2.num == INTMAX_MAX ); + VERIFY( r2.den == INTMAX_MAX - 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::ratio_divide< + std::ratio<INTMAX_MAX, 2>, + std::ratio<INTMAX_MAX, 2>>::type r1; + + VERIFY( r1.num == 1 ); + VERIFY( r1.den == 1 ); + + std::ratio_divide< + std::ratio<INTMAX_MAX-1, 2>, + std::ratio<INTMAX_MAX, 2>>::type r2; + + VERIFY( r2.num == INTMAX_MAX - 1 ); + VERIFY( r2.den == INTMAX_MAX ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc new file mode 100644 index 000000000..214ae7e19 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008, 2009 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/>. + +#include <ratio> + +void +test01() +{ + std::ratio_add<std::ratio<INTMAX_MAX, 1>, std::ratio<1>>::type r1; +} + +void +test02() +{ + std::ratio_multiply<std::ratio<-INTMAX_MAX, 2>, std::ratio<3, 2>>::type r1; + std::ratio_multiply<std::ratio<INTMAX_MAX>, std::ratio<INTMAX_MAX>>::type r2; +} + +// { dg-error "instantiated from here" "" { target *-*-* } 29 } +// { dg-error "instantiated from here" "" { target *-*-* } 35 } +// { dg-error "instantiated from here" "" { target *-*-* } 36 } +// { dg-error "overflow in addition" "" { target *-*-* } 130 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 98 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 100 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 102 } +// { dg-excess-errors "In instantiation of" } +// { dg-excess-errors "out of range" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc new file mode 100644 index 000000000..865e2885a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2003, 2007, 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/>. + +// 20.4.2 raw storage iterator + +#include <memory> + +void test01() +{ + using namespace std; + + // Check for required base class. + long l; + typedef raw_storage_iterator<long*, long> test_iterator; + typedef iterator<output_iterator_tag, void, void, void, void> base_iterator; + test_iterator rs_it(&l); + base_iterator* base __attribute__((unused)) = &rs_it; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..906954681 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <memory> + +template class std::raw_storage_iterator<int*, int>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc new file mode 100644 index 000000000..a62bde782 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 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/>. + +// 20.4.2 raw storage iterator + +#include <memory> + +void test01() +{ + using namespace std; + + // Check for required typedefs + typedef raw_storage_iterator<long*, long> test_iterator; + typedef test_iterator::value_type value_type; + typedef test_iterator::difference_type difference_type; + typedef test_iterator::pointer pointer; + typedef test_iterator::reference reference; + typedef test_iterator::iterator_category iteratory_category; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc new file mode 100644 index 000000000..3f9b54c3e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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 <functional> + +struct test_type +{ + int member(); + int cmember()const; + int member2(char); + int cmember2(char)const; +}; + +struct functor1 : public std::unary_function<int, double> +{ + double operator()(int) const; +}; + +struct functor2 : public std::binary_function<int, char, double> +{ + double operator()(int, char) const; +}; + +template <class T> +void verify_return_type(T, T) +{ +} + +void test01() +{ + test_type* null_tt = 0; + const test_type* null_ttc = 0; + int zero; + + std::reference_wrapper<double (int)>* pr1(0); + verify_return_type((*pr1)(0), double()); + std::reference_wrapper<double (*)(int)>* pr2(0); + verify_return_type((*pr2)(0), double()); + std::reference_wrapper<int (test_type::*)()>* pr3(0); + verify_return_type((*pr3)(null_tt), int()); + std::reference_wrapper<int (test_type::*)()const>* pr4(0); + verify_return_type((*pr4)(null_ttc), int()); + std::reference_wrapper<functor1>* pr5(0); + + // libstdc++/24803 + // FIXME: verify_return_type((*pr5)(0), double()); + verify_return_type((*pr5)(zero), double()); + + std::reference_wrapper<double (int, char)>* pr1b(0); + verify_return_type((*pr1b)(0,0), double()); + std::reference_wrapper<double (*)(int, char)>* pr2b(0); + verify_return_type((*pr2b)(0,0), double()); + std::reference_wrapper<int (test_type::*)(char)>* pr3b(0); + verify_return_type((*pr3b)(null_tt,zero), int()); + std::reference_wrapper<int (test_type::*)()const>* pr4b(0); + verify_return_type((*pr4b)(null_ttc), int()); + std::reference_wrapper<functor2>* pr5b(0); + + // libstdc++/24803 + // FIXME: verify_return_type((*pr5b)(0,0), double()); + verify_return_type((*pr5b)(zero,zero), double()); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc new file mode 100644 index 000000000..4427133d5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc @@ -0,0 +1,114 @@ +// { dg-options "-std=gnu++0x" } + +// 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 <functional> +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +struct X +{ + typedef int result_type; + + X() : bar(17) {} + + int foo(float x) { return truncate_float(x); } + int foo_c(float x) const { return truncate_float(x); } + int foo_v(float x) volatile { return truncate_float(x); } + int foo_cv(float x) const volatile { return truncate_float(x); } + + int operator()(float x) + { + return foo(x) + 1; + } + + int operator()(float x) const + { + return foo_c(x) + 2; + } + + int bar; + + private: + X(const X&); + X& operator=(const X&); +}; + +int seventeen() { return 17; } + +struct get_seventeen +{ + typedef int result_type; + int operator()() const { return 17; } +}; + +void test01() +{ + using std::ref; + using std::cref; + + ::get_seventeen get_sev; + ::X x; + ::X* xp = &x; + int (::X::* p_foo)(float) = &::X::foo; + int (::X::* p_foo_c)(float) const = &::X::foo_c; + int (::X::* p_foo_v)(float) volatile = &::X::foo_v; + int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv; + int ::X::* p_bar = &::X::bar; + + const float pi = 3.14; + + // Functions + VERIFY(ref(truncate_float)(pi) == 3); + VERIFY(ref(seventeen)() == 17); + + // Function pointers + VERIFY(cref(&truncate_float)(pi) == 3); + VERIFY(cref(&seventeen)() == 17); + + // Member function pointers + VERIFY(ref(p_foo)(x, pi) == 3); + VERIFY(ref(p_foo)(xp, pi) == 3); + VERIFY(ref(p_foo_c)(x, pi) == 3); + VERIFY(ref(p_foo_c)(xp, pi) == 3); + VERIFY(ref(p_foo_v)(x, pi) == 3); + VERIFY(ref(p_foo_v)(xp, pi) == 3); + VERIFY(ref(p_foo_cv)(x, pi) == 3); + VERIFY(ref(p_foo_cv)(xp, pi) == 3); + + // Member data pointers + VERIFY(ref(p_bar)(x) == 17); + VERIFY(ref(p_bar)(xp) == 17); + + // Function objects + VERIFY(ref(get_sev)() == 17); + VERIFY(cref(get_sev)() == 17); + VERIFY(ref(x)(pi) == 4); + VERIFY(cref(x)(pi) == 5); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc new file mode 100644 index 000000000..56ee29e1a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc @@ -0,0 +1,87 @@ +// { dg-options "-std=gnu++0x" } + +// 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 <functional> +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +struct X {}; + +struct int_result_type { typedef int result_type; }; + +struct derives_unary : std::unary_function<int, int> {}; + +struct derives_binary : std::binary_function<int, float, int> {}; + +struct derives_unary_binary + : std::unary_function<int, int>, + std::binary_function<int, float, int> +{ + typedef int result_type; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::reference_wrapper; + using std::is_same; + using std::is_convertible; + using std::unary_function; + using std::binary_function; + + // Check result_type typedef + VERIFY((is_same<reference_wrapper<int_result_type>::result_type, int>::value)); + VERIFY((is_same<reference_wrapper<derives_unary>::result_type, int>::value)); + VERIFY((is_same<reference_wrapper<derives_binary>::result_type, int>::value)); + VERIFY((is_same<reference_wrapper<derives_unary_binary>::result_type, int>::value)); + VERIFY((is_same<reference_wrapper<int(void)>::result_type, int>::value)); + VERIFY((is_same<reference_wrapper<int(*)(void)>::result_type, int>::value)); + VERIFY((is_same<reference_wrapper<int (::X::*)()>::result_type, int>::value)); + VERIFY((is_same<reference_wrapper<int (::X::*)(float)>::result_type, int>::value)); + + // Check derivation from unary_function + VERIFY((is_convertible<reference_wrapper<derives_unary>*, unary_function<int, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<derives_unary_binary>*, unary_function<int, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int(int)>*, unary_function<int, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int(*)(int)>*, unary_function<int, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)()>*, unary_function< ::X*, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)() const>*, unary_function<const ::X*, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)() volatile>*, unary_function<volatile ::X*, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)() const volatile>*, unary_function<const volatile ::X*, int>*>::value)); + + // Check derivation from binary_function + VERIFY((is_convertible<reference_wrapper<derives_binary>*, binary_function<int, float, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<derives_unary_binary>*, binary_function<int, float, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int(int, float)>*, binary_function<int, float, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int(*)(int, float)>*, binary_function<int, float, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)(float)>*, binary_function< ::X*, float, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) const>*, binary_function<const ::X*, float, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) volatile>*, binary_function<volatile ::X*, float, int>*>::value)); + VERIFY((is_convertible<reference_wrapper<int (::X::*)(float) const volatile>*, binary_function<const volatile ::X*, float, int>*>::value)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/rel_ops.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/rel_ops.cc new file mode 100644 index 000000000..534b4b626 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/rel_ops.cc @@ -0,0 +1,45 @@ +// 2002-04-13 Paolo Carlini <pcarlini@unitus.it> + +// Copyright (C) 2002, 2004, 2005, 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/>. + +// 20.2.1 Operators + +#include <utility> +#include <vector> + +using namespace std::rel_ops; + +// libstdc++/3628 +void test01() +{ + std::vector<int> v; + std::vector<int>::iterator vi; + v.push_back(1); + vi = v.end(); + vi != v.begin(); + vi > v.begin(); + vi <= v.begin(); + vi >= v.begin(); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..aeffd5a0f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 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/>. + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct remove_reference<test_type>; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/remove_reference/value.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/remove_reference/value.cc new file mode 100644 index 000000000..a412303d0 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/remove_reference/value.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007, 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 <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::remove_reference; + using std::is_same; + using namespace __gnu_test; + + VERIFY( (is_same<remove_reference<int&>::type, int>::value) ); + VERIFY( (is_same<remove_reference<int>::type, int>::value) ); + VERIFY( (is_same<remove_reference<const int&>::type, const int>::value) ); + VERIFY( (is_same<remove_reference<int*&>::type, int*>::value) ); + VERIFY( (is_same<remove_reference<ClassType&>::type, ClassType>::value) ); + VERIFY( (is_same<remove_reference<ClassType>::type, ClassType>::value) ); + VERIFY( (is_same<remove_reference<int(&)(int)>::type, int(int)>::value) ); + VERIFY( (is_same<remove_reference<int&&>::type, int>::value) ); + VERIFY( (is_same<remove_reference<int>::type, int>::value) ); + VERIFY( (is_same<remove_reference<const int&&>::type, const int>::value) ); + VERIFY( (is_same<remove_reference<int*&&>::type, int*>::value) ); + VERIFY( (is_same<remove_reference<ClassType&&>::type, ClassType>::value) ); + VERIFY( (is_same<remove_reference<ClassType>::type, ClassType>::value) ); + VERIFY( (is_same<remove_reference<int(&&)(int)>::type, int(int)>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc new file mode 100644 index 000000000..7c93eb077 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from shared_ptr<Y> +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + + a = std::shared_ptr<A>(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a = std::shared_ptr<A>(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc new file mode 100644 index 000000000..e8c751bba --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from auto_ptr<Y> +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a(new A); + std::auto_ptr<B> b(new B); + a = b; + VERIFY( a.get() != 0 ); + VERIFY( b.get() == 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc new file mode 100644 index 000000000..155449438 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible auto_ptr<Y> +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::auto_ptr<B> b; + a = b; // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "In constructor" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc new file mode 100644 index 000000000..376e8945f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x -Wno-deprecated" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +std::auto_ptr<A> source() { return std::auto_ptr<A>(); } + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from rvalue auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + a = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::auto_ptr<A> au; + a = std::move(au); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc new file mode 100644 index 000000000..48ddf9053 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +// DR 541. shared_ptr template assignment and void +void test01() +{ + std::shared_ptr<void> p; + p.operator=<void>(p); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc new file mode 100644 index 000000000..1a7b20caf --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc @@ -0,0 +1,118 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <utility> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Rvalue assignment from shared_ptr +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1; + std::shared_ptr<A> a2(new A); + + a1 = std::move(a2); + VERIFY( a1.get() != 0 ); + VERIFY( a2.get() == 0 ); + VERIFY( a1.use_count() == 1 ); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a1 = std::move(std::shared_ptr<A>()); + VERIFY( a1.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +// Rvalue assignment from shared_ptr<Y> +void +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::shared_ptr<B> b(new B); + + a = std::move(b); + VERIFY( a.get() != 0 ); + VERIFY( b.get() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( b.use_count() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + a = std::move(std::shared_ptr<A>()); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc new file mode 100644 index 000000000..4543be696 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc @@ -0,0 +1,96 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from shared_ptr<Y> +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + + a = std::shared_ptr<A>(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + a = std::shared_ptr<A>(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + a = std::shared_ptr<B>(new B); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc new file mode 100644 index 000000000..4d9d1a666 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> // { dg-excess-errors "In file included from" } +#include <testsuite_hooks.h> + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible shared_ptr<Y> +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::shared_ptr<B> b; + a = b; // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-error "In member function" "" { target *-*-* } 0 } +// { dg-error "cannot convert" "" { target *-*-* } 0 } +// { dg-error "instantiated from" "" { target *-*-* } 0 } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc new file mode 100644 index 000000000..b4fc8263e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from lvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::unique_ptr<A> u; + a = u; // { dg-error "used here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "deleted function" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc new file mode 100644 index 000000000..e759a42c3 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +std::unique_ptr<A> source() { return std::unique_ptr<A>(); } + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from rvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + a = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::unique_ptr<A> u; + a = std::move(u); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc new file mode 100644 index 000000000..a12c54964 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2006, 2007, 2009 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.6.6.2.10 shared_ptr casts [util.smartptr.shared.cast] + +#include <memory> +#include <testsuite_tr1.h> + +// { dg-do compile } + +struct MyP { virtual ~MyP() { }; }; +struct MyDP : MyP { }; + +int main() +{ + using __gnu_test::check_ret_type; + using std::shared_ptr; + using std::static_pointer_cast; + using std::const_pointer_cast; + using std::dynamic_pointer_cast; + + shared_ptr<double> spd; + shared_ptr<const int> spci; + shared_ptr<MyP> spa; + + check_ret_type<shared_ptr<void> >(static_pointer_cast<void>(spd)); + check_ret_type<shared_ptr<int> >(const_pointer_cast<int>(spci)); + check_ret_type<shared_ptr<MyDP> >(static_pointer_cast<MyDP>(spa)); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc new file mode 100644 index 000000000..3e9db7580 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc @@ -0,0 +1,98 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.6.2.6 shared_ptr comparison [util.smartptr.shared.cmp] + +int +test01() +{ + // test empty shared_ptrs compare equivalent + std::shared_ptr<A> p1; + std::shared_ptr<B> p2; + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p2 < p1) ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + std::shared_ptr<A> A_default; + + std::shared_ptr<A> A_from_A(new A); + VERIFY( A_default != A_from_A ); + VERIFY( !(A_default == A_from_A) ); + VERIFY( (A_default < A_from_A) || (A_from_A < A_default) ); + + std::shared_ptr<B> B_from_B(new B); + VERIFY( B_from_B != A_from_A ); + VERIFY( !(B_from_B == A_from_A) ); + VERIFY( (B_from_B < A_from_A) || (A_from_A < B_from_B) ); + + A_from_A.reset(); + VERIFY( A_default == A_from_A ); + VERIFY( !(A_default != A_from_A) ); + VERIFY( !(A_default < A_from_A) && !(A_from_A < A_default) ); + + B_from_B.reset(); + VERIFY( B_from_B == A_from_A ); + VERIFY( !(B_from_B != A_from_A) ); + VERIFY( !(B_from_B < A_from_A) && !(A_from_A < B_from_B) ); + + return 0; +} + +int +test03() +{ + std::shared_ptr<A> p1; + + // check other operators are defined + VERIFY( p1 <= p1 ); + VERIFY( p1 >= p1 ); + VERIFY( !(p1 > p1) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc new file mode 100644 index 000000000..7f35dbe80 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc @@ -0,0 +1,96 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.13.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +namespace std +{ + template<> + struct less<A*> : binary_function<A*,A*,bool> + { + static int count; + bool operator()(A* l, A* r) { ++count; return l < r; } + }; + int less<A*>::count = 0; +} + +// 20.8.13.2.7 shared_ptr comparison [util.smartptr.shared.cmp] + + +int +test01() +{ + std::less<std::shared_ptr<A>> less; + // test empty shared_ptrs compare equivalent + std::shared_ptr<A> p1; + std::shared_ptr<A> p2; + VERIFY( !less(p1, p2) && !less(p2, p1) ); + VERIFY( std::less<A*>::count == 2 ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + std::less<std::shared_ptr<A>> less; + + std::shared_ptr<A> empty; + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(new A); + + VERIFY( less(p1, p2) || less(p2, p1) ); + VERIFY( !(less(p1, p2) && less(p2, p1)) ); + + p1.reset(); + VERIFY( !less(p1, empty) && !less(empty, p1) ); + + p2.reset(); + VERIFY( !less(p1, p2) && !less(p2, p1) ); + + return 0; +} + +// Aliasing +int +test03() +{ + std::less<std::shared_ptr<A>> less; + + A a; + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1, &a); + VERIFY( less(p1, p2) || less(p2, p1) ); + + return 0; +} +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc new file mode 100644 index 000000000..d5b3f7dea --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 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/>. + +#include <memory> + +// libstdc++/39405 +template<typename T> + struct foo + { + std::shared_ptr<foo<T> > m_foo; + }; + +std::shared_ptr<foo<int> > t; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc new file mode 100644 index 000000000..9c39ed50d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc @@ -0,0 +1,107 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() : i() { } + virtual ~A() { } + int i; +}; + +struct B : A +{ + B() : A(), a() { } + virtual ~B() { } + A a; +}; + +void deletefunc(A* p) { delete p; } + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Aliasing constructors + +int test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::shared_ptr<bool> b1(a, &test); + VERIFY( b1.use_count() == 0 ); + VERIFY( a.get() == 0 ); + VERIFY( b1.get() == &test ); + + std::shared_ptr<bool> b2(b1); + VERIFY( b2.use_count() == 0 ); + VERIFY( b1.get() == b2.get() ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a(new A); + std::shared_ptr<int> i1(a, &a->i); + VERIFY( i1.use_count() == 2 ); + + std::shared_ptr<int> i2(i1); + VERIFY( i2.use_count() == 3 ); + VERIFY( i2.get() == &a->i ); + + return 0; +} + +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a1(b, b.get()); + std::shared_ptr<A> a2(b, &b->a); + VERIFY( a2.use_count() == 3 ); + VERIFY( a1 == b ); + VERIFY( a2 != b ); + VERIFY( a1.get() != a2.get() ); + + std::shared_ptr<A> a3(a1); + VERIFY( a3 == b ); + + a3 = a2; + VERIFY( a3.get() == &b->a ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc new file mode 100644 index 000000000..4a4be9a68 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc @@ -0,0 +1,103 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A { }; +void deletefunc(A* p) { delete p; } +struct D +{ + void operator()(A* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction with allocator +int +test01() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + std::shared_ptr<A> p1(new A, deletefunc, tracker_allocator<A>()); + std::size_t const sz = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz > 0 ); + { + std::shared_ptr<A> p2(p1); + VERIFY( p2.use_count() == 2 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + } + VERIFY( p1.use_count() == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + p1.reset(); + VERIFY( p1.use_count() == 0 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz ); + + return 0; +} + +// Construction with allocator +int +test02() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + std::shared_ptr<A> p1(new A, deletefunc, tracker_allocator<A>()); + std::size_t const sz1 = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz1 > 0 ); + std::shared_ptr<A> p2(new A, D(), tracker_allocator<A>()); + std::size_t const sz2 = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz2 > sz1 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + p1 = p2; + VERIFY( p2.use_count() == 2 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 ); + p1.reset(); + VERIFY( p2.use_count() == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 ); + p2.reset(); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz2 ); + VERIFY( D::delete_count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc new file mode 100644 index 000000000..9087e518a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> a(new A); + std::shared_ptr<A> a2(a); + VERIFY( a.get() == 0 ); + VERIFY( a2.get() != 0 ); + VERIFY( a2.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc new file mode 100644 index 000000000..3a946b587 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.const] + +// Construction from const auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + const std::auto_ptr<A> a; + std::shared_ptr<A> p(a); // { dg-error "no match" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "candidates are" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc new file mode 100644 index 000000000..c5dcffea0 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc @@ -0,0 +1,136 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +void deleter(A* p) { delete p; } + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Copy construction +int test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1; + std::shared_ptr<A> a2(a1); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1(new A); + std::shared_ptr<A> a2(a1); + VERIFY( a2.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a(b); + VERIFY( a.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B, &deleter); + std::shared_ptr<A> a(b); + VERIFY( a.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc new file mode 100644 index 000000000..ec4c1fdab --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Default construction +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + VERIFY( a.get() == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc new file mode 100644 index 000000000..795155829 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc @@ -0,0 +1,164 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 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/>. + +// TR1 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <utility> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct D +{ + void operator()(B* p) const { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + D::delete_count = 0; + } +}; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Rvalue construction +int test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1; + std::shared_ptr<A> a2(std::move(a1)); + VERIFY( a1.use_count() == 0 ); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1(new A); + std::shared_ptr<A> a2(std::move(a1)); + VERIFY( a1.use_count() == 0 ); + VERIFY( a2.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + return 0; +} + +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a(std::move(b)); + VERIFY( b.use_count() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B, D()); + std::shared_ptr<A> a(std::move(b)); + VERIFY( b.use_count() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + a = std::move(std::shared_ptr<A>()); + VERIFY( D::delete_count == 1 ); + VERIFY( B::dtor_count == 1 ); + + return 0; +} + +int +test05() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a(std::move(std::shared_ptr<A>(new A))); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc new file mode 100644 index 000000000..4bb528011 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B : A { }; + + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from pointer + +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = 0; + std::shared_ptr<A> p(a); + VERIFY( p.get() == 0 ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr<A> p(a); + VERIFY( p.get() == a ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + + +int +test03() +{ + bool test __attribute__((unused)) = true; + + B * const b = new B; + std::shared_ptr<A> p(b); + VERIFY( p.get() == b ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc new file mode 100644 index 000000000..cfca90d90 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> up(new A); + std::shared_ptr<A> sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc new file mode 100644 index 000000000..67485aee7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +struct D { + void operator()(A* p) const { delete p; ++count; } + static int count; +}; + +int D::count = 0; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A, D> up(new A, D()); + { + std::shared_ptr<A> sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + } + VERIFY( D::count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc new file mode 100644 index 000000000..d0998c94c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +struct D { + typedef void result_type; + void operator()(A* p) { delete p; ++count; } + int count; +}; + + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + D d = D(); + std::unique_ptr<A, D&> up(new A, d); + { + std::shared_ptr<A> sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + } + VERIFY( d.count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc new file mode 100644 index 000000000..7b09cfa7d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <functional> +#include <testsuite_hooks.h> + +struct A { }; + +struct D { + typedef void result_type; + void operator()(A* p) { delete p; ++count; } + int count; +}; + + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +// See: http://gcc.gnu.org/ml/libstdc++/2008-09/msg00070.html. +int +test01() +{ + bool test __attribute__((unused)) = true; + + D d; + std::unique_ptr<A, D&> p1(new A, d); + + std::shared_ptr<A> p2(std::move(p1)); + + typedef std::reference_wrapper<D> D2; + D2* p3 = std::get_deleter<D2>(p2); + + VERIFY( p3 != 0 ); + VERIFY( &p3->get() == &d ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc new file mode 100644 index 000000000..37bdb0b87 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from lvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> a; + std::shared_ptr<A> p(a); // { dg-error "used here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "deleted function" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc new file mode 100644 index 000000000..7e24c1822 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from weak_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr<A> a1(a); + std::weak_ptr<A> wa(a1); + std::shared_ptr<A> a2(wa); + VERIFY( a2.get() == a ); + VERIFY( a2.use_count() == wa.use_count() ); + + return 0; +} + + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc new file mode 100644 index 000000000..cff9b3b99 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from expired weak_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1(new A); + std::weak_ptr<A> wa(a1); + a1.reset(); + VERIFY( wa.expired() ); + try + { + std::shared_ptr<A> a2(wa); + } + catch (const std::bad_weak_ptr&) + { + // Expected. + __throw_exception_again; + } + catch (...) + { + // Failed. + } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc new file mode 100644 index 000000000..31230776e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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/>. + +#include <memory> + +struct A : std::enable_shared_from_this<A> { }; + +// libstdc++/36949 +void test01() +{ + std::make_shared<A>()->shared_from_this(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc new file mode 100644 index 000000000..e6bc6f47f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc @@ -0,0 +1,110 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A +{ + A(int i, double d, char c = '\0') : i(i), d(d), c(c) { ++ctor_count; } + explicit A(int i) : i(i), d(), c() { ++ctor_count; } + A() : i(), d(), c() { ++ctor_count; } + ~A() { ++dtor_count; } + int i; + double d; + char c; + static int ctor_count; + static int dtor_count; +}; +int A::ctor_count = 0; +int A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + tracker_allocator_counter::reset(); + } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + { + std::shared_ptr<A> p1 = std::allocate_shared<A>(tracker_allocator<A>()); + VERIFY( p1.get() != 0 ); + VERIFY( p1.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + } + VERIFY( A::ctor_count == A::dtor_count ); + VERIFY( tracker_allocator_counter::get_allocation_count() + == tracker_allocator_counter::get_deallocation_count() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + std::shared_ptr<A> p1; + + p1 = std::allocate_shared<A>(tracker_allocator<A>(), 1); + VERIFY( A::ctor_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + + p1 = std::allocate_shared<A>(tracker_allocator<A>(), 1, 2.0); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() > 0 ); + + p1 = std::allocate_shared<A>(tracker_allocator<A>(), 1, 2.0, '3'); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( p1->i == 1 ); + VERIFY( p1->d == 2.0 ); + VERIFY( p1->c == '3' ); + + p1 = std::shared_ptr<A>(); + VERIFY( A::ctor_count == A::dtor_count ); + VERIFY( tracker_allocator_counter::get_allocation_count() + == tracker_allocator_counter::get_deallocation_count() ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc new file mode 100644 index 000000000..462c6f848 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <new> +#include <testsuite_hooks.h> + +struct A +{ + void* operator new(size_t n) { return new char[sizeof(A)]; } + void operator delete(void* p, size_t) { delete (char*)p; } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p = std::make_shared<A>(); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc new file mode 100644 index 000000000..2441b9302 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc @@ -0,0 +1,97 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A(int i, double d, char c = '\0') : i(i), d(d), c(c) { ++ctor_count; } + explicit A(int i) : i(i), d(), c() { ++ctor_count; } + A() : i(), d(), c() { ++ctor_count; } + ~A() { ++dtor_count; } + int i; + double d; + char c; + static int ctor_count; + static int dtor_count; +}; +int A::ctor_count = 0; +int A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + { + std::shared_ptr<A> p1 = std::make_shared<A>(); + VERIFY( p1.get() != 0 ); + VERIFY( p1.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + } + VERIFY( A::ctor_count == A::dtor_count ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + std::shared_ptr<A> p1; + + p1 = std::make_shared<A>(1); + VERIFY( A::ctor_count == 1 ); + + p1 = std::make_shared<A>(1, 2.0); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + + p1 = std::make_shared<A>(1, 2.0, '3'); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( p1->i == 1 ); + VERIFY( p1->d == 2.0 ); + VERIFY( p1->c == '3' ); + + p1 = std::shared_ptr<A>(); + VERIFY( A::ctor_count == A::dtor_count ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc new file mode 100644 index 000000000..5e1a6135f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct D +{ + void operator()(const B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + D::delete_count = 0; + } +}; + + +// 20.6.6.2.2 shared_ptr destructor [util.smartptr.shared.dest] + +// empty shared_ptr +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + { + std::shared_ptr<A> a; + } + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + VERIFY( D::delete_count == 0 ); + + return 0; +} + +// shared ownership +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + { + a = std::shared_ptr<A>(new B, D()); + } + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + VERIFY( D::delete_count == 0 ); + + return 0; +} + +// exclusive ownership +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + { + std::shared_ptr<A> a1(new B); + std::shared_ptr<A> a2(new B, D()); + } + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 2 ); + VERIFY( B::dtor_count == 2 ); + VERIFY( D::delete_count == 1 ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc new file mode 100644 index 000000000..b44c9bdf8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +using std::get_deleter; + +// libstdc++/24595 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<int> sp; + VERIFY( !get_deleter<void(*)(int*)>(sp) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc new file mode 100644 index 000000000..a84f4bebf --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <sstream> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.8 shared_ptr I/O [util.smartptr.shared.io] + +// operator<< +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p(new A); + std::ostringstream buf; + buf << p; + const std::string s = buf.str(); + buf.str(""); + buf << p.get(); + VERIFY( s == buf.str() ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc new file mode 100644 index 000000000..10ccf8cad --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.9 shared_ptr specialized algorithms [util.smartptr.shared.spec] + +// std::swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a1 = new A; + A * const a2 = new A; + std::shared_ptr<A> p1(a1); + std::shared_ptr<A> p2(a2); + std::swap(p1, p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc new file mode 100644 index 000000000..8b64014c0 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap + +// libstdc++/24805 +using std::swap; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc new file mode 100644 index 000000000..c3b6745b4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc @@ -0,0 +1,89 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B : A { }; +struct D +{ + void operator()(B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// reset +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr<A> p1(a); + std::shared_ptr<A> p2(p1); + p1.reset(); + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == a ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + B * const b = new B; + std::shared_ptr<A> p1(a); + std::shared_ptr<A> p2(p1); + p1.reset(b); + VERIFY( p1.get() == b ); + VERIFY( p2.get() == a ); + + return 0; +} + +int +test03() +{ + bool test __attribute__((unused)) = true; + + { + std::shared_ptr<A> p1; + p1.reset(new B, D()); + } + VERIFY( D::delete_count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc new file mode 100644 index 000000000..61ac3b98e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A { }; +struct B : A { }; +struct D +{ + void operator()(B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// Reset with allocator +int +test01() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + { + std::shared_ptr<A> p1; + p1.reset(new B, D(), tracker_allocator<B>()); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + } + VERIFY( D::delete_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count() ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc new file mode 100644 index 000000000..5f133f547 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// reset +int +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1(new A); + p1.reset(); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc new file mode 100644 index 000000000..aab41ddc8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a1 = new A; + A * const a2 = new A; + std::shared_ptr<A> p1(a1); + std::shared_ptr<A> p2(a2); + p1.swap(p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc new file mode 100644 index 000000000..db173630f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(new A); + p1.swap(p2); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_rvalue.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_rvalue.cc new file mode 100644 index 000000000..0ace59b1c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_rvalue.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.7.12.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p(new A); + p.swap(std::shared_ptr<A>(new A)); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc new file mode 100644 index 000000000..f57284fa2 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// conversion to bool +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1; + VERIFY( p1 == false ); + const std::shared_ptr<A> p2(p1); + VERIFY( p2 == false ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + VERIFY( p1 ); + std::shared_ptr<A> p2(p1); + VERIFY( p2 ); + p1.reset(); + VERIFY( !p1 ); + VERIFY( p2 ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p2.reset(new A); + VERIFY( p1 ); + VERIFY( p2 ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc new file mode 100644 index 000000000..104c7219d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() : i() {} + int i; +}; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// get +void +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr<A> p(a); + VERIFY( p.get() == a ); +} + +// operator* +void +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr<A> p(a); + VERIFY( &*p == a ); +} + +// operator-> +void +test03() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr<A> p(a); + VERIFY( &p->i == &a->i ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc new file mode 100644 index 000000000..79ede6833 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc @@ -0,0 +1,94 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.13.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + int i; + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty shared_ptrs compare equivalent + std::shared_ptr<A> p1; + std::shared_ptr<B> p2; + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); +} + + +// Construction from pointer +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a0; + + std::shared_ptr<A> a1(new A); + VERIFY( a1.owner_before(a0) || a0.owner_before(a1) ); + VERIFY( !(a1.owner_before(a0) && a0.owner_before(a1)) ); + + std::shared_ptr<B> b1(new B); + VERIFY( a1.owner_before(b1) || b1.owner_before(a1) ); + VERIFY( !(a1.owner_before(b1) && b1.owner_before(a1)) ); + + std::shared_ptr<A> a2(a1); + VERIFY( !a1.owner_before(a2) && !a2.owner_before(a1) ); + a2 = b1; + VERIFY( !b1.owner_before(a2) && !a2.owner_before(b1) ); + + std::weak_ptr<A> w1(a1); + VERIFY( !a1.owner_before(w1) && !w1.owner_before(a1) ); + std::weak_ptr<A> w2(a2); + VERIFY( !b1.owner_before(w2) && !w2.owner_before(b1) ); +} + +// Aliasing +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A()); + std::shared_ptr<int> p2(p1, &p1->i); + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc new file mode 100644 index 000000000..fae5eba37 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// unique +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1; + VERIFY( !p1.unique() ); + const std::shared_ptr<A> p2(p1); + VERIFY( !p1.unique() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + VERIFY( p1.unique() ); + std::shared_ptr<A> p2(p1); + VERIFY( !p1.unique() ); + p1.reset(); + VERIFY( !p1.unique() ); + VERIFY( p2.unique() ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p2.reset(new A); + VERIFY( p1.unique() ); + VERIFY( p2.unique() ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc new file mode 100644 index 000000000..a7f34cfac --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B : A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// use_count +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1; + VERIFY( p1.use_count() == 0 ); + const std::shared_ptr<A> p2(p1); + VERIFY( p1.use_count() == 0 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p1.reset(); + VERIFY( p1.use_count() == 0 ); + VERIFY( p2.use_count() == 1 ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p2.reset(new B); + VERIFY( p1.use_count() == 1 ); + VERIFY( p2.use_count() == 1 ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..0f2d2c366 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::shared_ptr; +template class shared_ptr<int>; +template class shared_ptr<void>; +template class shared_ptr<ClassType>; +template class shared_ptr<IncompleteClass>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..781657cb0 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +// Check the _S_single lock policy can be instantiated. For a thread-enabled +// library this checks the templates can be instantiated for non-default +// lock policy, for a single-threaded lib this is redundant but harmless. +using namespace __gnu_test; +using std::__shared_ptr; +using std::_S_single; +template class __shared_ptr<int, _S_single>; +template class __shared_ptr<ClassType, _S_single>; +template class __shared_ptr<IncompleteClass, _S_single>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc new file mode 100644 index 000000000..42239a324 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc @@ -0,0 +1,194 @@ +// Copyright (C) 2006, 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthread -std=gnu++0x" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthreads -std=gnu++0x" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } + +#include <memory> +#include <random> +#include <vector> +#include <testsuite_hooks.h> +#include <iostream> +#include <cstdlib> + +#include <pthread.h> + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +/* This (brute-force) tests the atomicity and thus thread safety of the + * shared_ptr <- weak_ptr + * assignment operation by allocating a test object, retrieving a weak + * reference to it, and letting a number of threads repeatedly create strong + * references from the weak reference. + * Specifically, this tests the function _Sp_counted_base<true>::add_ref_lock() + */ + + +const unsigned int HAMMER_MAX_THREADS = 10; +const unsigned int POOL_SIZE = 1000; +const unsigned long HAMMER_REPEAT = 100000; +const unsigned long KILL_ONE_IN = 1000; + +struct A + { + static _Atomic_word counter; + A() + { + __gnu_cxx::__atomic_add(&counter, 1); + } + ~A() + { + __gnu_cxx::__atomic_add(&counter, -1); + } + }; + +_Atomic_word A::counter = 0; + +typedef std::shared_ptr<A> sp_A_t; +typedef std::weak_ptr<A> wp_A_t; + +typedef std::vector<sp_A_t> sp_vector_t; +typedef std::vector<wp_A_t> wp_vector_t; + +struct shared_and_weak_pools +{ + sp_vector_t& shared_pool; + wp_vector_t& weak_pool; + + shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool) + : shared_pool(_shared_pool), weak_pool(_weak_pool) + { } +}; + +void* thread_hammer_and_kill(void* opaque_pools) +{ + shared_and_weak_pools& pools = *static_cast<shared_and_weak_pools*>(opaque_pools); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18> rng; + + sp_vector_t::iterator cur_shared = pools.shared_pool.begin(); + wp_vector_t::iterator cur_weak = pools.weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == pools.weak_pool.end()) + break; + } + + if (rng() % KILL_ONE_IN == 0) + { + cur_shared->reset(); + ++cur_shared; + } + } + return 0; +} + +void* thread_hammer(void* opaque_weak) +{ + wp_vector_t& weak_pool = *static_cast<wp_vector_t*>(opaque_weak); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18> rng; + wp_vector_t::iterator cur_weak = weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == weak_pool.end()) + break; + } + } + return 0; +} + +int +test01() +{ + bool test __attribute__((unused)) = true; + sp_vector_t obj_pool(POOL_SIZE); + + for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur) + { + cur->reset(new A); + } + // Obtain weak references. + std::vector<wp_vector_t> weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end())); + + // Launch threads with pointer to weak reference. + pthread_t threads[HAMMER_MAX_THREADS]; +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (HAMMER_MAX_THREADS); +#endif + + pthread_attr_t tattr; + pthread_attr_init(&tattr); + + shared_and_weak_pools pools(obj_pool, weak_pool[0]); + pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast<void*>(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, static_cast<void*>(&weak_pool[worker]))) + std::abort(); + } + // Wait for threads to complete, then check integrity of reference. + void* status; + for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_join(threads[worker], &status)) + std::abort(); + } + obj_pool.clear(); + + VERIFY( A::counter == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc new file mode 100644 index 000000000..e4ac7ee8c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc @@ -0,0 +1,196 @@ +// Copyright (C) 2006, 2007, 2008, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } + +#include <memory> +#include <random> +#include <vector> +#include <testsuite_hooks.h> +#include <iostream> +#include <cstdlib> + +#include <pthread.h> + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +/* This (brute-force) tests the atomicity and thus thread safety of the + * shared_ptr <- weak_ptr + * assignment operation by allocating a test object, retrieving a weak + * reference to it, and letting a number of threads repeatedly create strong + * references from the weak reference. + * Specifically, this tests the function _Sp_counted_base<true>::add_ref_lock() + */ + + +const unsigned int HAMMER_MAX_THREADS = 10; +const unsigned int POOL_SIZE = 1000; +const unsigned long HAMMER_REPEAT = 100000; +const unsigned long KILL_ONE_IN = 1000; + +struct A + { + static _Atomic_word counter; + A() + { + __gnu_cxx::__atomic_add(&counter, 1); + } + ~A() + { + __gnu_cxx::__atomic_add(&counter, -1); + } + }; + +_Atomic_word A::counter = 0; + +using std::_S_mutex; + +typedef std::__shared_ptr<A, _S_mutex> sp_A_t; +typedef std::__weak_ptr<A, _S_mutex> wp_A_t; + +typedef std::vector<sp_A_t> sp_vector_t; +typedef std::vector<wp_A_t> wp_vector_t; + +struct shared_and_weak_pools +{ + sp_vector_t& shared_pool; + wp_vector_t& weak_pool; + + shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool) + : shared_pool(_shared_pool), weak_pool(_weak_pool) + { } +}; + +void* thread_hammer_and_kill(void* opaque_pools) +{ + shared_and_weak_pools& pools = *static_cast<shared_and_weak_pools*>(opaque_pools); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18> rng; + + sp_vector_t::iterator cur_shared = pools.shared_pool.begin(); + wp_vector_t::iterator cur_weak = pools.weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == pools.weak_pool.end()) + break; + } + + if (rng() % KILL_ONE_IN == 0) + { + cur_shared->reset(); + ++cur_shared; + } + } + return 0; +} + +void* thread_hammer(void* opaque_weak) +{ + wp_vector_t& weak_pool = *static_cast<wp_vector_t*>(opaque_weak); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18> rng; + wp_vector_t::iterator cur_weak = weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == weak_pool.end()) + break; + } + } + return 0; +} + +int +test01() +{ + bool test __attribute__((unused)) = true; + sp_vector_t obj_pool(POOL_SIZE); + + for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur) + { + cur->reset(new A); + } + // Obtain weak references. + std::vector<wp_vector_t> weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end())); + + // Launch threads with pointer to weak reference. + pthread_t threads[HAMMER_MAX_THREADS]; +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (HAMMER_MAX_THREADS); +#endif + + pthread_attr_t tattr; + pthread_attr_init(&tattr); + + shared_and_weak_pools pools(obj_pool, weak_pool[0]); + pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast<void*>(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, static_cast<void*>(&weak_pool[worker]))) + std::abort(); + } + // Wait for threads to complete, then check integrity of reference. + void* status; + for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_join(threads[worker], &status)) + std::abort(); + } + obj_pool.clear(); + + VERIFY( A::counter == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc new file mode 100644 index 000000000..a869ea8a8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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 Pred 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/>. + +#undef _GLIBCXX_CONCEPT_CHECKS +#define _GLIBCXX_TESTSUITE_ALLOW_RVALREF_ALIASING + +#include <algorithm> +#include <iterator> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::uninitialized_copy; + +typedef test_container<rvalstruct, input_iterator_wrapper> container_in; +typedef test_container<rvalstruct, forward_iterator_wrapper> container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + uninitialized_copy(std::move_iterator<input_iterator_wrapper<rvalstruct> >(incon.begin()), + std::move_iterator<input_iterator_wrapper<rvalstruct> >(incon.end()), + outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc new file mode 100644 index 000000000..f54f2f5ad --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 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 Pred 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/>. + +#undef _GLIBCXX_CONCEPT_CHECKS +#define _GLIBCXX_TESTSUITE_ALLOW_RVALREF_ALIASING + +#include <algorithm> +#include <iterator> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::uninitialized_copy_n; + +typedef test_container<rvalstruct, input_iterator_wrapper> container_in; +typedef test_container<rvalstruct, forward_iterator_wrapper> container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + uninitialized_copy_n(std::move_iterator<input_iterator_wrapper<rvalstruct> >(incon.begin()), + size, outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc new file mode 100644 index 000000000..961be2fdb --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2007, 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/>. + +// 20.4.4 specialized algorithms + +// { dg-do compile } + +#include <memory> +#include <utility> + +// c++/32158 + +typedef std::pair<const int, int> MyPair; + +void +Alpha(MyPair* start, MyPair* end) +{ + MyPair my_pair(1, 2); + std::uninitialized_fill(start, end, my_pair); +}; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc new file mode 100644 index 000000000..380c53d39 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004, 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/>. + +// 20.4.4 specialized algorithms + +// { dg-do compile } + +#include <memory> + +// libstdc++/16505 + +struct S { }; + +template + void + std::uninitialized_fill_n<S*, int, S>(S*, int, const S&); diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/temporary_buffer.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/temporary_buffer.cc new file mode 100644 index 000000000..7266f9e2d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/temporary_buffer.cc @@ -0,0 +1,49 @@ +// 2002-01-24 Phil Edwards <pme@gcc.gnu.org> + +// Copyright (C) 2002, 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/>. + +// 20.4.3 temporary buffers + +#include <memory> +#include <testsuite_hooks.h> + +struct junk { char j[12]; }; + +int main(void) +{ + bool test __attribute__((unused)) = true; + + std::pair<junk*,ptrdiff_t> results = std::get_temporary_buffer<junk>(5); + + if (results.second != 0) + { + // make sure it works: test the returned capacity, and then construct + // some junk in the buffer. + // XXX + VERIFY( results.first != 0 ); + } + else + { + // if it says it didn't work, make sure it didn't work + VERIFY( results.first == 0 ); + } + + std::return_temporary_buffer(results.first); + + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/1.cc new file mode 100644 index 000000000..e18c6e58c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.4 Class template time_point [time.point] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.4.1 time_point constructors [time.point.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1; + VERIFY(t1.time_since_epoch() == system_clock::duration::zero()); + + time_point<monotonic_clock> t2; + VERIFY(t2.time_since_epoch() == monotonic_clock::duration::zero()); + + time_point<high_resolution_clock> t3; + VERIFY(t3.time_since_epoch() == high_resolution_clock::duration::zero()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/2.cc new file mode 100644 index 000000000..8aab7ac69 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/2.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.4 Class template time_point [time.point] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.4.3 time_point arithmetic [time.point.arithmetic] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1, t2; + t1 += seconds(1); + VERIFY(t2.time_since_epoch() + seconds(1) == t1.time_since_epoch()); + + t1 -= std::chrono::seconds(1); + VERIFY(t2.time_since_epoch() == t1.time_since_epoch()); +} + +// 20.8.4.5 time_point non-member arithmetic [time.point.nonmember] +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1; + time_point<system_clock> t2(t1 + seconds(1)); + VERIFY(t2.time_since_epoch() == t1.time_since_epoch() + seconds(1)); + + time_point<system_clock> t3(seconds(1) + t1); + VERIFY(t3.time_since_epoch() == t1.time_since_epoch() + seconds(1)); + + time_point<system_clock> t4(seconds(1)); + time_point<system_clock> t5(seconds(2)); + + time_point<system_clock> t6(t5 - seconds(1)); + VERIFY(t6.time_since_epoch() == t4.time_since_epoch()); + + time_point<system_clock> t7(t5 - t4); + VERIFY(t7.time_since_epoch() == t4.time_since_epoch()); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/3.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/3.cc new file mode 100644 index 000000000..ebf75b12f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/3.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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.4 Class template time_point [time.point] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.4.6 time_point comparisons [time.point.comparisons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1(seconds(1)); + time_point<system_clock> t2(seconds(1)); + time_point<system_clock> t3(seconds(2)); + + VERIFY(t1 == t2); + VERIFY(t1 != t3); + VERIFY(t1 < t3); + VERIFY(t1 <= t3); + VERIFY(t1 <= t2); + VERIFY(t3 > t1); + VERIFY(t3 >= t1); + VERIFY(t2 >= t1); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..5c0455d65 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 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/>. + +#include <chrono> + +template class std::chrono::time_point<std::chrono::system_clock>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480.cc new file mode 100644 index 000000000..613c27f8b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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/>. + +// Tuple + +#include <tuple> + +// libstdc++/35480 +void test01() +{ + std::tuple<int> t1( 1 ); + std::tuple<int, int> t2( 1, 2 ); + if ( t1 < t2 ) {} // { dg-error "here" } + if ( t1 == t2 ) {} // { dg-error "here" } +} +// { dg-excess-errors "incomplete type" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc new file mode 100644 index 000000000..c10fb1cbc --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +bool test __attribute__((unused)) = true; + +#define TEST1(x) VERIFY( x == x && !(x != x) && x <= x && !(x < x) ) + +int +main() +{ + int i=0; + int j=0; + int k=2; + tuple<int, int, int> a(0, 0, 0); + tuple<int, int, int> b(0, 0, 1); + tuple<int& , int& , int&> c(i,j,k); + tuple<const int&, const int&, const int&> d(c); + TEST1(a); + TEST1(b); + TEST1(c); + TEST1(d); + VERIFY(!(a > a) && !(b > b)); + VERIFY(a >= a && b >= b); + VERIFY(a < b && !(b < a) && a <= b && !(b <= a)); + VERIFY(b > a && !(a > b) && b >= a && !(a >= b)); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc new file mode 100644 index 000000000..111a398ff --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + tuple<> ta; + tuple<> tb; + ta = tb; + + tuple<int> tc(1); + tuple<int> td(0); + td = tc; + VERIFY(get<0>(td) == 1); + + int i=0; + tuple<int&> te(i); + te = tc; + VERIFY(i == 1); + + tuple<const int&> tf(tc); + + get<0>(tc) = 2; + VERIFY(get<0>(tf) == 2); + tuple<double> tg; + tg = tc; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc new file mode 100644 index 000000000..f979623e9 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc @@ -0,0 +1,104 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +// A simple class without conversions to check some things +struct foo +{ }; + +void +test_constructors() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple<int,int> tb; + // Test construction from values + tuple<int,int> tc(x1,x2); + tuple<int,int&> td(x1,x2); + tuple<const int&> te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple<int,int> tf(tc); + tuple<int,int> tg(td); + tuple<const int&> th(te); + // Test different tuple copy constructor + tuple<int,double> ti(tc); + tuple<int,double> tj(td); + // Test constructing from a pair + pair<int,int> pair1(1,1); + const pair<int,int> pair2(pair1); + tuple<int,int> tl(pair1); + tuple<int,const int&> tm(pair1); + tuple<int,int> tn(pair2); + tuple<int,const int&> to(pair2); +} + +int +main(void) +{ + //test construction + typedef tuple<int,int,int,int,int,int,int,int,int,int> type1; + type1 a(0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + type1 b(0, 0, 0, 0, 0, 0, 0, 0, 0, 2); + type1 c(a); + typedef tuple<int,int,int,int,int,int,int,int,int,char> type2; + type2 d(0, 0, 0, 0, 0, 0, 0, 0, 0, 3); + type1 e(d); + typedef tuple<foo,int,int,int,int,int,int,int,int,foo> type3; + // get + VERIFY(get<9>(a)==1 && get<9>(b)==2); + // comparisons + VERIFY(a==a && !(a!=a) && a<=a && a>=a && !(a<a) && !(a>a)); + VERIFY(!(a==b) && a!=b && a<=b && a<b && !(a>=b) && !(a>b)); + //tie + { + int i = 0; + tie(ignore, ignore, ignore, ignore, ignore, ignore, ignore, ignore, + ignore, i) = a; + VERIFY(i == 1); + } + //test_assignment + a=d; + a=b; + //make_tuple + make_tuple(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + //tuple_size + VERIFY(tuple_size<type3>::value == 10); + //tuple_element + { + foo q1; + tuple_element<0,type3>::type q2(q1); + tuple_element<9,type3>::type q3(q1); + } +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc new file mode 100644 index 000000000..3afb059ce --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple<int,int> tb; + // Test construction from values + tuple<int,int> tc(x1,x2); + tuple<int,int&> td(x1,x2); + tuple<const int&> te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple<int,int> tf(tc); + tuple<int,int> tg(td); + tuple<const int&> th(te); + // Test different tuple copy constructor + tuple<int,double> ti(tc); + tuple<int,double> tj(td); + //tuple<int&, int&> tk(tc); + tuple<const int&, const int&> tl(tc); + tuple<const int&, const int&> tm(tl); + // Test constructing from a pair + pair<int,int> pair1(1,1); + const pair<int,int> pair2(pair1); + tuple<int,int> tn(pair1); + tuple<int,const int&> to(pair1); + tuple<int,int> tp(pair2); + tuple<int,const int&> tq(pair2); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc new file mode 100644 index 000000000..7db57bc70 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <utility> +#include <testsuite_hooks.h> + +using namespace std; + +// libstdc++/23978 +void test01() +{ + bool test __attribute__((unused)) = true; + + pair<int, int> p(1, 2); + int x = 0; + int y = 0; + tie(x, y) = p; + VERIFY( x == 1 && y == 2 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc new file mode 100644 index 000000000..7521111fa --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <functional> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int i=0; + make_tuple(1,2,4.0); + make_tuple(ref(i)) = tuple<int>(1); + VERIFY(i == 1); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc new file mode 100644 index 000000000..a76928979 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1 = 0; + int x2 = 0; + int y1 = 0; + int y2 = 0; + tuple<int,int> ta(1,1); + tuple<const int&,const int&> tc(x1,x2); + tie(y1,y2)=ta; + VERIFY(y1 == 1 && y2 == 1); + tie(y1,y2)=tc; + VERIFY(y1 == 0 && y2 == 0); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc new file mode 100644 index 000000000..538c3e8e1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <string> +#include <testsuite_hooks.h> + +int +main() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + int i; + string s; + + tie(i, ignore, s) = make_tuple(42, 3.14, "C++"); + VERIFY( i == 42 ); + VERIFY( s == "C++" ); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc new file mode 100644 index 000000000..1ec01cfca --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int j=1; + const int k=2; + tuple<int,int &,const int&> a(0,j,k); + const tuple<int,int &,const int&> b(1,j,k); + VERIFY(get<0>(a)==0 && get<1>(a)==1 && get<2>(a)==2); + get<0>(a)=3; + get<1>(a)=4; + VERIFY(get<0>(a)==3 && get<1>(a)==4); + VERIFY(j==4); + get<1>(b)=5; + VERIFY(get<0>(b)==1 && get<1>(b)==5 && get<2>(b)==2); + VERIFY(j==5); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/moveable.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/moveable.cc new file mode 100644 index 000000000..0fedd83ed --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/moveable.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include <tuple> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int, double> a(1, 2.0), b; + b = std::move(a); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + VERIFY( std::get<0>(a) == 1 && std::get<1>(a) == 2.0 ); + + std::tuple<int, double> c(std::move(b)); + VERIFY( std::get<0>(c) == 1 && std::get<1>(c) == 2.0 ); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc new file mode 100644 index 000000000..f08007421 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// 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 <tuple> +#include <utility> + +struct MoveOnly +{ + MoveOnly () { } + + MoveOnly (MoveOnly&&) { } + + MoveOnly& operator=(MoveOnly&&) + { return *this; } + +private: + MoveOnly(MoveOnly const&); // = delete + MoveOnly& operator=(MoveOnly const&); // = delete +}; + +MoveOnly +make_move_only () +{ return MoveOnly(); } + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00046.html +void test01() +{ + typedef std::tuple<MoveOnly> move_only_tuple; + + move_only_tuple t1(make_move_only()); + move_only_tuple t2(std::move(t1)); + move_only_tuple t3 = std::move(t2); + t1 = std::move(t3); + + typedef std::tuple<MoveOnly, MoveOnly> move_only_tuple2; + + move_only_tuple2 t4(make_move_only(), make_move_only()); + move_only_tuple2 t5(std::move(t4)); + move_only_tuple2 t6 = std::move(t5); + t4 = std::move(t6); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..22b8f50f5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 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 <tuple> + +template class std::tuple<short, int, double>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/swap.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/swap.cc new file mode 100644 index 000000000..1e65f0521 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/swap.cc @@ -0,0 +1,109 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include <tuple> +#include <utility> +#include <testsuite_hooks.h> + +struct MoveOnly +{ + explicit MoveOnly (int j) : i(j) { } + + MoveOnly (MoveOnly&& m) : i(m.i) { } + + MoveOnly& operator=(MoveOnly&& m) + { i = m.i; return *this; } + + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + + bool operator==(MoveOnly const& m) + { return i == m.i; } + + void swap(MoveOnly&& m) + { std::swap(m.i, i); } + + int i; +}; + +void swap(MoveOnly& m1, MoveOnly& m2) +{ m1.swap(m2); } + +MoveOnly +make_move_only (int i) +{ return MoveOnly(i); } + +void test01() +{ + std::tuple<> t1, t2; + std::swap(t1, t2); + + VERIFY( t1 == t2 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int> t1(1), t2(2); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int, float> t1(1, 1.0f), t2(2, 2.0f); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int, float, MoveOnly> + t1(1, 1.0f, make_move_only(1)), + t2(2, 2.0f, make_move_only(2)); + + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); + VERIFY( std::get<2>(t1) == make_move_only(2) + && std::get<2>(t2) == make_move_only(1) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc new file mode 100644 index 000000000..9344ea082 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> + +using namespace std; + +struct foo +{ }; + +int +main() +{ + // As foo isn't constructible from anything else, this + // lets us check if type is returning foo when it should + foo q1; + tuple_element<0,tuple<foo,void,int> >::type q2(q1); + tuple_element<2,tuple<void,int,foo> >::type q3(q1); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc new file mode 100644 index 000000000..51f4a2db8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 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/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + VERIFY(tuple_size<tuple<> >::value == 0); + VERIFY(tuple_size<tuple<int> >::value == 1); + VERIFY(tuple_size<tuple<void> >::value == 1); + typedef tuple<int,const int&,void> test_tuple1; + VERIFY(tuple_size<test_tuple1>::value == 3); + VERIFY(tuple_size<tuple<tuple<void> > >::value == 1); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc new file mode 100644 index 000000000..af4641b2c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc @@ -0,0 +1,58 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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/>. + +#include <memory> + +struct base { virtual ~base() {} }; +struct derived : base {}; + +void +test01() +{ + std::unique_ptr<derived> p1(new derived); + std::unique_ptr<derived> p2(new derived); +// p2 = p1; // should not compile + p2 = std::move(p1); + std::unique_ptr<base> p3(new base); +// p3 = p2; // should not compile + p3 = std::move(p2); +} + +void +test02() +{ + std::unique_ptr<int[]> p1(new int(420)); + std::unique_ptr<int[]> p2 = p1; +} + +void +test03() +{ + std::unique_ptr<int[2]> p1(new int[3]); + std::unique_ptr<int[2]> p2 = p1; +} + +// { dg-error "used here" "" { target *-*-* } 42 } +// { dg-error "no matching" "" { target *-*-* } 48 } +// { dg-error "used here" "" { target *-*-* } 49 } +// { dg-error "candidates are" "" { target *-*-* } 214 } +// { dg-error "deleted function" "" { target *-*-* } 214 } +// { dg-error "deleted function" "" { target *-*-* } 360 } +// { dg-excess-errors "note" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc new file mode 100644 index 000000000..75529c969 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D; + std::unique_ptr<D> p1(d); + std::unique_ptr<D> p2(new D); + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); + + std::unique_ptr<B> p3(new B); + p3 = std::move(p2); + + VERIFY( p2.get() == 0 ); + VERIFY( p3.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc new file mode 100644 index 000000000..b1b878d5d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D[3]; + std::unique_ptr<D[]> p1(d); + std::unique_ptr<D[]> p2; + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc new file mode 100644 index 000000000..324264b24 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc @@ -0,0 +1,117 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.6.11.2.1 unique_ptr constructors [unique.ptr.single.ctor] + +// Construction from pointer +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr<A> A_from_A(new A); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr<A> A_from_B(new B); + VERIFY( A_from_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); +} + +void +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + A * const A_default = 0; + std::unique_ptr<A> p1(A_default); + VERIFY( p1.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + A * const A_from_A = new A; + std::unique_ptr<A> p2(A_from_A); + VERIFY( p2.get() == A_from_A ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc new file mode 100644 index 000000000..dcd6e92f1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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/>. + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.4.5.1 unique_ptr constructors [unique.ptr.cons] + +// Construction from pointer +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr<A[]> A_from_A(new A[3]); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible.cc new file mode 100644 index 000000000..7e0f30741 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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/>. + +#include <memory> + +struct A +{ +}; + +struct B : A +{ + virtual ~B() { } +}; + +// 20.4.5.1 unique_ptr constructors [unique.ptr.cons] + +// Construction from pointer of derived type +void +test01() +{ + std::unique_ptr<B[]> B_from_A(new A[3]); //{ dg-error "invalid conversion from" } +} +//{ dg-excess-errors "initialization" } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc new file mode 100644 index 000000000..fbf3e7712 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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/>. + +#include <memory> + +struct A +{ +}; + +struct B : A +{ + virtual ~B() { } +}; + +void test01() +{ + std::unique_ptr<B[]> up; + up.reset(new A[3]); +} + +// { dg-error "used here" "" { target *-*-* } 35 } +// { dg-error "deleted function" "" { target *-*-* } 350 } diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..dd308094b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 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/>. + +#include <memory> + +template class std::unique_ptr<int>; +template class std::unique_ptr<int[]>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc new file mode 100644 index 000000000..70bf90905 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p1; + std::unique_ptr<A> p2; + + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p1 > p2) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p1; + std::unique_ptr<A> p2(new A); + + VERIFY( p1 != p2 ); + VERIFY( !(p1 == p2) ); + VERIFY( (p1 < p2) || (p1 > p2) ); + VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc new file mode 100644 index 000000000..ccb429282 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> p1; + std::unique_ptr<A[]> p2; + + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p1 > p2) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> p1; + std::unique_ptr<A[]> p2(new A[3]); + + VERIFY( p1 != p2 ); + VERIFY( !(p1 == p2) ); + VERIFY( (p1 < p2) || (p1 > p2) ); + VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc new file mode 100644 index 000000000..fa0c31173 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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/>. + +#include <memory> +#include <testsuite_hooks.h> + +struct A {}; + +//20.6.11.5 unique_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p1; + std::unique_ptr<A> p2(new A); + std::unique_ptr<A> p3; + + std::swap(p3, p2); + + VERIFY( p1 != p3 ); + VERIFY( p2 != p3 ); + VERIFY( p1 == p2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc new file mode 100644 index 000000000..f73f5c761 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x " } +// { dg-do compile } + +// Copyright (C) 2008, 2009 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.6.6.3 Template class weak_ptr [util.smartptr.weak] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.8.13.3.6 weak_ptr comparison [util.smartptr.weak.cmp] (removed) + +int +test01() +{ + std::weak_ptr<A> p1; + // { dg-excess-errors "deleted function" } + p1 < p1; // { dg-error "used here" } + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc new file mode 100644 index 000000000..ccaed290e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc @@ -0,0 +1,36 @@ +// 2006-09-24 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2007, 2009 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.6.6.3 Template class weak_ptr [util.smartptr.weak] + +#include <memory> +#include <testsuite_tr1.h> + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +int main() +{ + using __gnu_test::check_ret_type; + using std::weak_ptr; + using std::shared_ptr; + + weak_ptr<int> wp; + check_ret_type<shared_ptr<int> >(wp.lock()); +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc new file mode 100644 index 000000000..786e7eb16 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 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.13.3 Template class weak_ptr [util.smartptr.weak] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B { }; + +// 20.6.6.3.5 weak_ptr observers [util.smartptr.weak.obs] + +int +test01() +{ + // test empty weak_ptrs compare equivalent + std::weak_ptr<A> p1; + std::weak_ptr<B> p2; + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); + + std::shared_ptr<B> p3; + VERIFY( !p1.owner_before(p3) && !p3.owner_before(p1) ); + + return 0; +} + + +int +test02() +{ + std::shared_ptr<A> a0; + std::weak_ptr<A> w0(a0); + + std::shared_ptr<A> a1(new A); + std::weak_ptr<A> w1(a1); + VERIFY( !a1.owner_before(w1) && !w1.owner_before(a1) ); + + VERIFY( w1.owner_before(w0) || w0.owner_before(w1) ); + VERIFY( !(w1.owner_before(w0) && w0.owner_before(w1)) ); + + VERIFY( w1.owner_before(a0) || a0.owner_before(w1) ); + VERIFY( !(w1.owner_before(a0) && a0.owner_before(w1)) ); + + std::shared_ptr<B> b1(new B); + VERIFY( w1.owner_before(b1) || b1.owner_before(w1) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..ebfc94351 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::weak_ptr; +template class weak_ptr<int>; +template class weak_ptr<void>; +template class weak_ptr<ClassType>; +template class weak_ptr<IncompleteClass>; diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..db49600b8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +// Check the _S_single lock policy can be instantiated. For a thread-enabled +// library this checks the templates can be instantiated for non-default +// lock policy, for a single-threaded lib this is redundant but harmless. +using namespace __gnu_test; +using std::__weak_ptr; +using std::_S_single; +template class __weak_ptr<int, _S_single>; +template class __weak_ptr<void, _S_single>; +template class __weak_ptr<ClassType, _S_single>; +template class __weak_ptr<IncompleteClass, _S_single>; |