diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2019-02-14 11:53:57 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2019-02-14 11:53:57 +0000 |
commit | 08668f0cf734379a7a7078ad4b67bf9ff8650e8d (patch) | |
tree | 99d734300608072a7557cc39027d3b7192b0c2a2 | |
parent | 14ce69d0cfa2ef20eaeb53f9abe63fdb7a821daa (diff) |
PR middle-end/89303 add testcase for std::enable_shared_from_this
* testsuite/20_util/enable_shared_from_this/89303.cc: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@268874 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc | 39 |
2 files changed, 44 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 78286676311d..d290dcf7e453 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2019-02-14 Jonathan Wakely <jwakely@redhat.com> + + PR middle-end/89303 + * testsuite/20_util/enable_shared_from_this/89303.cc: New test. + 2019-02-09 Jonathan Wakely <jwakely@redhat.com> Backport from mainline diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc new file mode 100644 index 000000000000..3b23332c35eb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2019 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/>. + +// { dg-options "-O1" } +// { dg-do run { target c++11 } } + +// PR middle-end/89303 + +#include <memory> + +class blob final: public std::enable_shared_from_this<blob> +{ + int* data; + +public: + blob() { data = new int; } + ~blob() { delete data; } +}; + +int +main() +{ + std::shared_ptr<blob> tg = std::make_shared<blob>(); + return tg->shared_from_this().use_count() - 2; +} |