| 1 | // { dg-do run { target c++11 } } |
| 2 | // { dg-options "-g -O0" } |
| 3 | // { dg-require-effective-target hosted } |
| 4 | |
| 5 | // Copyright (C) 2016-2025 Free Software Foundation, Inc. |
| 6 | // |
| 7 | // This file is part of the GNU ISO C++ Library. This library is free |
| 8 | // software; you can redistribute it and/or modify it under the |
| 9 | // terms of the GNU General Public License as published by the |
| 10 | // Free Software Foundation; either version 3, or (at your option) |
| 11 | // any later version. |
| 12 | |
| 13 | // This library is distributed in the hope that it will be useful, |
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // GNU General Public License for more details. |
| 17 | |
| 18 | // You should have received a copy of the GNU General Public License along |
| 19 | // with this library; see the file COPYING3. If not see |
| 20 | // <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | #include <memory> |
| 23 | |
| 24 | struct x_struct |
| 25 | { |
| 26 | int y; |
| 27 | }; |
| 28 | |
| 29 | int |
| 30 | main () |
| 31 | { |
| 32 | std::shared_ptr<int> p(new int(10)); |
| 33 | |
| 34 | std::shared_ptr<x_struct> q(new x_struct{23}); |
| 35 | |
| 36 | std::shared_ptr<x_struct[]> r(new x_struct[2]{ {46}, {69} }); |
| 37 | |
| 38 | std::shared_ptr<x_struct[3]> s(new x_struct[2]{ {92}, {115} }); |
| 39 | |
| 40 | auto qq = q; |
| 41 | |
| 42 | // { dg-final { note-test *p 10 } } |
| 43 | // { dg-final { regexp-test p.get() 0x.* } } |
| 44 | |
| 45 | // { dg-final { whatis-test *p int } } |
| 46 | // { dg-final { whatis-test p.get() "int \*" } } |
| 47 | |
| 48 | // { dg-final { note-test *q {\{y = 23\}} } } |
| 49 | // { dg-final { regexp-test q.get() 0x.* } } |
| 50 | // { dg-final { note-test q->y 23 } } |
| 51 | |
| 52 | // { dg-final { whatis-test *q x_struct } } |
| 53 | // { dg-final { whatis-test q.get() "x_struct \*" } } |
| 54 | // { dg-final { whatis-test q->y int } } |
| 55 | |
| 56 | // { dg-final { note-test r\[1] {\{y = 69\}} } } |
| 57 | // { dg-final { regexp-test r.get() 0x.* } } |
| 58 | // { dg-final { note-test r\[1].y 69 } } |
| 59 | |
| 60 | // { dg-final { whatis-test r\[1] x_struct } } |
| 61 | // { dg-final { whatis-test r.get() "x_struct \*" } } |
| 62 | // { dg-final { whatis-test r\[1].y int } } |
| 63 | |
| 64 | // { dg-final { note-test s\[1] {\{y = 115\}} } } |
| 65 | // { dg-final { regexp-test s.get() 0x.* } } |
| 66 | // { dg-final { note-test s\[1].y 115 } } |
| 67 | |
| 68 | // { dg-final { whatis-test s\[1] x_struct } } |
| 69 | // { dg-final { whatis-test s.get() "x_struct \*" } } |
| 70 | // { dg-final { whatis-test s\[1].y int } } |
| 71 | |
| 72 | // { dg-final { note-test p.use_count() 1 } } |
| 73 | // { dg-final { note-test p.unique() true } } |
| 74 | // { dg-final { note-test q.use_count() 2 } } |
| 75 | // { dg-final { note-test q.unique() false } } |
| 76 | |
| 77 | return 0; // Mark SPOT |
| 78 | } |
| 79 | |
| 80 | // { dg-final { gdb-test SPOT {} 1 } } |