diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2010-08-11 08:49:47 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2010-08-11 08:49:47 +0000 |
commit | 3abeaf8f89f246f481c869a09d0715a2762bde28 (patch) | |
tree | 7b9f9a2cd71a9f12a49311af70596d15abe4c21b /libstdc++-v3/testsuite | |
parent | 8fe286ea6d3807259c46054ea1f11d1a26ed4cc0 (diff) | |
download | gcc-3abeaf8f89f246f481c869a09d0715a2762bde28.zip gcc-3abeaf8f89f246f481c869a09d0715a2762bde28.tar.gz gcc-3abeaf8f89f246f481c869a09d0715a2762bde28.tar.bz2 |
re PR libstdc++/42925 ([GB 99] Not possible to compare unique_ptr with 0)
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42925
* include/bits/unique_ptr.h (operator==(const unique_ptr<>&,
nullptr_t), operator==(nullptr_t, const unique_ptr<>&),
operator!=(const unique_ptr<>&, nullptr_t),
operator!=(nullptr_t, const unique_ptr<>&)): Add.
* include/bits/shared_ptr_base.h (operator==(const __shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const __shared_ptr<>&),
operator!=(const __shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const __shared_ptr<>&)): Likewise.
* include/bits/shared_ptr.h (operator==(const shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const shared_ptr<>&),
operator!=(const shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const shared_ptr<>&)): Likewise.
* testsuite/20_util/unique_ptr/comparison/42925.cc: New.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust
dg-error line numbers.
From-SVN: r163094
Diffstat (limited to 'libstdc++-v3/testsuite')
3 files changed, 77 insertions, 3 deletions
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc new file mode 100644 index 0000000..41e09d6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 20.9.11.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> + +// libstdc++/42925 (also see GB 99) +void test01() +{ + std::shared_ptr<int> ptr; + if (ptr == 0) + { } + if (0 == ptr) + { } + if (ptr != 0) + { } + if (0 != ptr) + { } +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc new file mode 100644 index 0000000..e3dfad4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include <memory> + +// libstdc++/42925 (also see GB 99) +void test01() +{ + std::unique_ptr<int> ptr; + if (ptr == 0) + { } + if (0 == ptr) + { } + if (ptr != 0) + { } + if (0 != ptr) + { } +} diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc index ea84c7e..f124718 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -41,9 +41,9 @@ main() return 0; } -// { dg-warning "note" "" { target *-*-* } 327 } -// { dg-warning "note" "" { target *-*-* } 446 } -// { dg-warning "note" "" { target *-*-* } 863 } +// { dg-warning "note" "" { target *-*-* } 347 } +// { dg-warning "note" "" { target *-*-* } 466 } +// { dg-warning "note" "" { target *-*-* } 883 } // { dg-warning "note" "" { target *-*-* } 580 } // { dg-warning "note" "" { target *-*-* } 1027 } // { dg-warning "note" "" { target *-*-* } 340 } |