From: Jonathan Wakely Date: Wed, 10 Nov 2010 10:09:03 +0000 (+0000) Subject: unique_ptr.h: Use static_assert in constexpr constructors. X-Git-Tag: releases/gcc-4.6.0~2761 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef40b371064e5a1e26e26b3885ee0e0a5cb64b56;p=thirdparty%2Fgcc.git unique_ptr.h: Use static_assert in constexpr constructors. 2010-11-10 Jonathan Wakely * include/bits/unique_ptr.h: Use static_assert in constexpr constructors. * testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc: Remove xfails. * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust dg-error line number. From-SVN: r166525 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 51cf2eb1916a..ab60cb34e3d4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2010-11-10 Jonathan Wakely + + * include/bits/unique_ptr.h: Use static_assert in constexpr + constructors. + * testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc: Remove xfails. + * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust dg-error + line number. + 2010-11-09 François Dumont Johannes Singler @@ -15,6 +23,13 @@ * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust dg-error line number. +2010-11-08 Jonathan Wakely + + * include/bits/unique_ptr.h: Move misplaced static_assert and use + tuple's constexpr constructor in constexpr constructors. + * testsuite/20_util/unique_ptr/cons/ptr_deleter.cc: New. + * testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc: New. + 2010-11-08 Benjamin Kosnik * doc/doxygen/user.cfg.in: Adjust scanned includes. diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index ff1a9251dbcc..74367985858e 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -109,7 +109,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Constructors. constexpr unique_ptr() : _M_t() - { } + { static_assert(!std::is_pointer::value, + "constructed with null function pointer deleter"); } explicit unique_ptr(pointer __p) @@ -130,7 +131,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) constexpr unique_ptr(nullptr_t) : _M_t() - { } + { static_assert(!std::is_pointer::value, + "constructed with null function pointer deleter"); } // Move constructors. unique_ptr(unique_ptr&& __u) @@ -269,7 +271,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Constructors. constexpr unique_ptr() : _M_t() - { } + { static_assert(!std::is_pointer::value, + "constructed with null function pointer deleter"); } explicit unique_ptr(pointer __p) @@ -288,10 +291,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { static_assert(!std::is_reference::value, "rvalue deleter bound to reference"); } - /* TODO: use delegating constructor */ constexpr unique_ptr(nullptr_t) : _M_t() - { } + { static_assert(!std::is_pointer::value, + "constructed with null function pointer deleter"); } // Move constructors. unique_ptr(unique_ptr&& __u) diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc index 143578ed4b49..e765874c7255 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc @@ -30,9 +30,9 @@ using std::unique_ptr; void test01() { - unique_ptr p1; // { dg-error "here" "" { xfail *-*-* } } + unique_ptr p1; // { dg-error "here" } - unique_ptr p2(nullptr); // { dg-error "here" "" { xfail *-*-* } } + unique_ptr p2(nullptr); // { dg-error "here" } unique_ptr p3(new int); // { dg-error "here" } } @@ -40,9 +40,9 @@ test01() void test02() { - unique_ptr p1; // { dg-error "here" "" { xfail *-*-* } } + unique_ptr p1; // { dg-error "here" } - unique_ptr p2(nullptr); // { dg-error "here" "" { xfail *-*-* } } + unique_ptr p2(nullptr); // { dg-error "here" } unique_ptr p3(new int[1]); // { dg-error "here" } } 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 4e46c90faa9e..f0a1f6cb1d40 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 @@ -43,7 +43,7 @@ main() // { dg-warning "note" "" { target *-*-* } 350 } // { dg-warning "note" "" { target *-*-* } 1082 } -// { dg-warning "note" "" { target *-*-* } 462 } +// { dg-warning "note" "" { target *-*-* } 465 } // { dg-warning "note" "" { target *-*-* } 580 } // { dg-warning "note" "" { target *-*-* } 1027 } // { dg-warning "note" "" { target *-*-* } 340 }