]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/libstdc++-xmethods/unique_ptr.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-xmethods / unique_ptr.cc
CommitLineData
52066eae
JW
1// { dg-do run { target c++11 } }
2// { dg-options "-g -O0" }
e9e08827 3
8d9254fc 4// Copyright (C) 2014-2020 Free Software Foundation, Inc.
e9e08827
SCR
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
419587a0
DE
23struct x_struct
24{
25 int y;
26};
27
e9e08827
SCR
28int
29main ()
30{
0376e86b 31 std::unique_ptr<int> p(new int(10));
419587a0 32
0376e86b
JW
33 std::unique_ptr<x_struct> q(new x_struct{23});
34
35 std::unique_ptr<x_struct[]> r(new x_struct[2]{ {46}, {69} });
419587a0 36
e9e08827
SCR
37// { dg-final { note-test *p 10 } }
38// { dg-final { regexp-test p.get() 0x.* } }
39
8996b63b
DE
40// { dg-final { whatis-test *p int } }
41// { dg-final { whatis-test p.get() "int \*" } }
42
419587a0
DE
43// { dg-final { note-test *q {\{y = 23\}} } }
44// { dg-final { regexp-test q.get() 0x.* } }
45// { dg-final { note-test q->y 23 } }
46
47// { dg-final { whatis-test *q x_struct } }
48// { dg-final { whatis-test q.get() "x_struct \*" } }
49// { dg-final { whatis-test q->y int } }
50
0376e86b
JW
51// { dg-final { note-test r\[1] {\{y = 69\}} } }
52// { dg-final { regexp-test r.get() 0x.* } }
53// { dg-final { note-test r\[1].y 69 } }
54
55// { dg-final { whatis-test r\[1] x_struct } }
56// { dg-final { whatis-test r.get() "x_struct \*" } }
57// { dg-final { whatis-test r\[1].y int } }
58
59
e9e08827
SCR
60 return 0; // Mark SPOT
61}
62
63// { dg-final { gdb-test SPOT {} 1 } }