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/unique_ptr/assign/48635.cc | 78 ++++++++++++++++++++++ .../20_util/unique_ptr/assign/48635_neg.cc | 50 ++++++++++++++ .../20_util/unique_ptr/assign/assign_neg.cc | 53 +++++++++++++++ .../testsuite/20_util/unique_ptr/assign/move.cc | 52 +++++++++++++++ .../20_util/unique_ptr/assign/move_array.cc | 46 +++++++++++++ .../testsuite/20_util/unique_ptr/assign/nullptr.cc | 54 +++++++++++++++ 6 files changed, 333 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc (limited to 'libstdc++-v3/testsuite/20_util/unique_ptr/assign') diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc new file mode 100644 index 000000000..99b412b58 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 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 +// . + +#include +#include + +struct Deleter +{ + Deleter() = default; + Deleter(const Deleter&) = default; + Deleter(Deleter&&) = default; + + Deleter& + operator=(const Deleter&) + { + bool test __attribute__((unused)) = true; + VERIFY( true ); + return *this; + } + + Deleter& + operator=(Deleter&&) + { + bool test __attribute__((unused)) = true; + VERIFY( false ); + return *this; + } + + template + void + operator()(T*) const { } +}; + +struct DDeleter : Deleter { }; + +// libstdc++/48635 +void test01() +{ + Deleter d; + + std::unique_ptr p1(nullptr, d), p2(nullptr, d); + p2 = std::move(p1); + + DDeleter dd; + + std::unique_ptr p1t(nullptr, dd); + std::unique_ptr p2t(nullptr, d); + p2t = std::move(p1t); + + std::unique_ptr p1a(nullptr, d), p2a(nullptr, d); + p2a = std::move(p1a); + + std::unique_ptr p1at(nullptr, dd); + std::unique_ptr p2at(nullptr, d); + p2at = std::move(p1at); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc new file mode 100644 index 000000000..1ed53ee2d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 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 +// . + +#include + +struct D; + +struct B +{ + B& operator=(D&) = delete; // { dg-error "declared here" } + + template + void operator()(T*) const {} +}; + +struct D : B { }; + +// libstdc++/48635 +void f() +{ + B b; + D d; + + std::unique_ptr ub(nullptr, b); + std::unique_ptr ud(nullptr, d); + ub = std::move(ud); +// { dg-error "use of deleted function" "" { target *-*-* } 189 } + + std::unique_ptr uba(nullptr, b); + std::unique_ptr uda(nullptr, d); + uba = std::move(uda); +// { dg-error "use of deleted function" "" { target *-*-* } 329 } +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc new file mode 100644 index 000000000..501bad385 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 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 +// . + +#include + +struct base { virtual ~base() {} }; +struct derived : base {}; + +void +test01() +{ + std::unique_ptr p1(new derived); + std::unique_ptr p2(new derived); +// p2 = p1; // should not compile + p2 = std::move(p1); + std::unique_ptr p3(new base); +// p3 = p2; // should not compile + p3 = std::move(p2); +} + +void +test02() +{ + std::unique_ptr p1(new int(420)); + std::unique_ptr p2 = p1; // { dg-error "deleted" } +} + +void +test03() +{ + std::unique_ptr p1(new int[3]); // { dg-error "no match" } + // { dg-error "candidate" "candidate-note" { target *-*-* } 48 } + std::unique_ptr p2 = p1; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc new file mode 100644 index 000000000..75529c969 --- /dev/null +++ b/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 +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D; + std::unique_ptr p1(d); + std::unique_ptr p2(new D); + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); + + std::unique_ptr p3(new B); + p3 = std::move(p2); + + VERIFY( p2.get() == 0 ); + VERIFY( p3.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc new file mode 100644 index 000000000..b1b878d5d --- /dev/null +++ b/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 +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D[3]; + std::unique_ptr p1(d); + std::unique_ptr p2; + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc new file mode 100644 index 000000000..6f067ee4d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 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.9.10 Class template unique_ptr [unique.ptr] + +#include +#include + +struct A { }; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p(new A); + p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p(new A[2]); + p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +int main() +{ + test01(); + test02(); + return 0; +} -- cgit v1.2.3