From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/20_util/shared_ptr/assign/assign.cc | 72 +++++++++++++ .../20_util/shared_ptr/assign/auto_ptr.cc | 85 +++++++++++++++ .../20_util/shared_ptr/assign/auto_ptr_neg.cc | 50 +++++++++ .../20_util/shared_ptr/assign/auto_ptr_rvalue.cc | 61 +++++++++++ .../testsuite/20_util/shared_ptr/assign/dr541.cc | 30 ++++++ .../testsuite/20_util/shared_ptr/assign/move.cc | 118 +++++++++++++++++++++ .../20_util/shared_ptr/assign/shared_ptr.cc | 96 +++++++++++++++++ .../20_util/shared_ptr/assign/shared_ptr_neg.cc | 52 +++++++++ .../shared_ptr/assign/unique_ptr_lvalue_neg.cc | 49 +++++++++ .../20_util/shared_ptr/assign/unique_ptr_rvalue.cc | 61 +++++++++++ 10 files changed, 674 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc (limited to 'libstdc++-v3/testsuite/20_util/shared_ptr/assign') diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc new file mode 100644 index 000000000..7c93eb077 --- /dev/null +++ b/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 +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +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 +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + + a = std::shared_ptr(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a = std::shared_ptr(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc new file mode 100644 index 000000000..e2ec07860 --- /dev/null +++ b/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 +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +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 +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a(new A); + std::auto_ptr b(new B); + a = std::move(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/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc new file mode 100644 index 000000000..b79a25b13 --- /dev/null +++ b/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 +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::auto_ptr b; + a = std::move(b); // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "In constructor" } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc new file mode 100644 index 000000000..376e8945f --- /dev/null +++ b/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 +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +std::auto_ptr source() { return std::auto_ptr(); } + +// 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 = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::auto_ptr au; + a = std::move(au); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc new file mode 100644 index 000000000..48ddf9053 --- /dev/null +++ b/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 +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include + +// DR 541. shared_ptr template assignment and void +void test01() +{ + std::shared_ptr p; + p.operator=(p); +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc new file mode 100644 index 000000000..1a7b20caf --- /dev/null +++ b/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 +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +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 a1; + std::shared_ptr 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()); + VERIFY( a1.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +// Rvalue assignment from shared_ptr +void +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::shared_ptr 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()); + 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/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc new file mode 100644 index 000000000..4543be696 --- /dev/null +++ b/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 +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +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 +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + + a = std::shared_ptr(); + 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(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(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/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc new file mode 100644 index 000000000..e0d09dee9 --- /dev/null +++ b/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 +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible shared_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::shared_ptr 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/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc new file mode 100644 index 000000000..dae967bfd --- /dev/null +++ b/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, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +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; + std::unique_ptr u; + a = u; // { dg-error "cannot bind" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "initializing argument" } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc new file mode 100644 index 000000000..e759a42c3 --- /dev/null +++ b/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 +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +std::unique_ptr source() { return std::unique_ptr(); } + +// 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 = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::unique_ptr u; + a = std::move(u); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} -- cgit v1.2.3