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