]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-xmethods / shared_ptr.cc
CommitLineData
0376e86b
JW
1// { dg-do run { target c++11 } }
2// { dg-options "-g -O0" }
7cc9022f 3// { dg-require-effective-target hosted }
0376e86b 4
a945c346 5// Copyright (C) 2016-2024 Free Software Foundation, Inc.
0376e86b
JW
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
24struct x_struct
25{
26 int y;
27};
28
29int
30main ()
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
37c8a083
JW
40 auto qq = q;
41
0376e86b
JW
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
37c8a083
JW
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
0376e86b
JW
77 return 0; // Mark SPOT
78}
79
80// { dg-final { gdb-test SPOT {} 1 } }