Fortran: implement F2018 intrinsic OUT_OF_RANGE [PR115788]
[gcc.git] / libstdc++-v3 / testsuite / libstdc++-xmethods / shared_ptr.cc
blobba3bd6d12141844f2d9532456fe98399ae871fa1
1 // { dg-do run { target c++11 } }
2 // { dg-options "-g -O0" }
3 // { dg-require-effective-target hosted }
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.
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.
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/>.
22 #include <memory>
24 struct x_struct
26 int y;
29 int
30 main ()
32 std::shared_ptr<int> p(new int(10));
34 std::shared_ptr<x_struct> q(new x_struct{23});
36 std::shared_ptr<x_struct[]> r(new x_struct[2]{ {46}, {69} });
38 std::shared_ptr<x_struct[3]> s(new x_struct[2]{ {92}, {115} });
40 auto qq = q;
42 // { dg-final { note-test *p 10 } }
43 // { dg-final { regexp-test p.get() 0x.* } }
45 // { dg-final { whatis-test *p int } }
46 // { dg-final { whatis-test p.get() "int \*" } }
48 // { dg-final { note-test *q {\{y = 23\}} } }
49 // { dg-final { regexp-test q.get() 0x.* } }
50 // { dg-final { note-test q->y 23 } }
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 } }
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 } }
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 } }
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 } }
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 } }
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 } }
77 return 0; // Mark SPOT
80 // { dg-final { gdb-test SPOT {} 1 } }