]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/89303 add testcase for std::enable_shared_from_this
authorJonathan Wakely <jwakely@redhat.com>
Mon, 2 Sep 2019 11:10:08 +0000 (12:10 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 2 Sep 2019 11:10:08 +0000 (12:10 +0100)
PR middle-end/89303
* testsuite/20_util/enable_shared_from_this/89303.cc: New test.

From-SVN: r275312

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc [new file with mode: 0644]

index e72eb882bf21984d9343fa3fa0138132d3aa80ab..07f86ba6ad299a538fcdc4906309fd2c89267f84 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-02  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR middle-end/89303
+       * testsuite/20_util/enable_shared_from_this/89303.cc: New test.
+
 2019-09-02  Jonathan Wakely  <jwakely@redhat.com>
 
        * testsuite/20_util/unique_ptr/assign/48635_neg.cc: Replace dg-error
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 (file)
index 0000000..3b23332
--- /dev/null
@@ -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;
+}