]>
Commit | Line | Data |
---|---|---|
52066eae JW |
1 | // { dg-do run { target c++11 } } |
2 | // { dg-options "-g -O0" } | |
8dfb08ab | 3 | |
8d9254fc | 4 | // Copyright (C) 2011-2020 Free Software Foundation, Inc. |
8dfb08ab JW |
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 <forward_list> | |
22 | #include <unordered_map> | |
23 | #include <unordered_set> | |
24 | #include <string> | |
d6222d4e | 25 | #include <memory> |
8dfb08ab | 26 | #include <iostream> |
066f9ea2 | 27 | #include "../util/testsuite_allocator.h" // NullablePointer |
8dfb08ab | 28 | |
c77efe8f PM |
29 | typedef std::tuple<int, int> ExTuple; |
30 | ||
8dfb08ab JW |
31 | template<class T> |
32 | void | |
33 | placeholder(const T &s) | |
34 | { | |
35 | std::cout << s; | |
36 | } | |
37 | ||
38 | template<class T, class S> | |
39 | void | |
40 | placeholder(const std::pair<T,S> &s) | |
41 | { | |
42 | std::cout << s.first; | |
43 | } | |
44 | ||
45 | template<class T> | |
46 | void | |
47 | use(const T &container) | |
48 | { | |
49 | for (typename T::const_iterator i = container.begin(); | |
50 | i != container.end(); | |
51 | ++i) | |
52 | placeholder(*i); | |
53 | } | |
54 | ||
c4269a63 TT |
55 | struct datum |
56 | { | |
57 | std::string s; | |
58 | int i; | |
59 | }; | |
60 | ||
61 | std::unique_ptr<datum> global; | |
62 | ||
8dfb08ab JW |
63 | int |
64 | main() | |
65 | { | |
66 | std::forward_list<int> efl; | |
3997383b | 67 | // { dg-final { regexp-test efl "empty std::(__debug::)?forward_list" } } |
8dfb08ab | 68 | |
c77efe8f | 69 | std::forward_list<int> &refl = efl; |
3997383b | 70 | // { dg-final { regexp-test refl "empty std::(__debug::)?forward_list" } } |
c77efe8f | 71 | |
8dfb08ab JW |
72 | std::forward_list<int> fl; |
73 | fl.push_front(2); | |
74 | fl.push_front(1); | |
3997383b | 75 | // { dg-final { regexp-test fl {std::(__debug::)?forward_list = {\[0\] = 1, \[1\] = 2}} } } |
8dfb08ab | 76 | |
c77efe8f | 77 | std::forward_list<int> &rfl = fl; |
3997383b | 78 | // { dg-final { regexp-test rfl {std::(__debug::)?forward_list = {\[0\] = 1, \[1\] = 2}} } } |
c77efe8f | 79 | |
8dfb08ab | 80 | std::unordered_map<int, std::string> eum; |
3997383b | 81 | // { dg-final { regexp-test eum "std::(__debug::)?unordered_map with 0 elements" } } |
c77efe8f | 82 | std::unordered_map<int, std::string> &reum = eum; |
3997383b | 83 | // { dg-final { regexp-test reum "std::(__debug::)?unordered_map with 0 elements" } } |
c77efe8f | 84 | |
8dfb08ab | 85 | std::unordered_multimap<int, std::string> eumm; |
3997383b | 86 | // { dg-final { regexp-test eumm "std::(__debug::)?unordered_multimap with 0 elements" } } |
c77efe8f | 87 | std::unordered_multimap<int, std::string> &reumm = eumm; |
3997383b | 88 | // { dg-final { regexp-test reumm "std::(__debug::)?unordered_multimap with 0 elements" } } |
c77efe8f | 89 | |
8dfb08ab | 90 | std::unordered_set<int> eus; |
3997383b | 91 | // { dg-final { regexp-test eus "std::(__debug::)?unordered_set with 0 elements" } } |
c77efe8f | 92 | std::unordered_set<int> &reus = eus; |
3997383b | 93 | // { dg-final { regexp-test reus "std::(__debug::)?unordered_set with 0 elements" } } |
c77efe8f | 94 | |
8dfb08ab | 95 | std::unordered_multiset<int> eums; |
3997383b | 96 | // { dg-final { regexp-test eums "std::(__debug::)?unordered_multiset with 0 elements" } } |
c77efe8f | 97 | std::unordered_multiset<int> &reums = eums; |
3997383b | 98 | // { dg-final { regexp-test reums "std::(__debug::)?unordered_multiset with 0 elements" } } |
8dfb08ab | 99 | |
d25b1e3a TT |
100 | std::unordered_map<int, std::string> uom; |
101 | uom[5] = "three"; | |
102 | uom[3] = "seven"; | |
3997383b | 103 | // { dg-final { regexp-test uom {std::(__debug::)?unordered_map with 2 elements = {\[3\] = "seven", \[5\] = "three"}} } } |
d25b1e3a | 104 | |
c77efe8f | 105 | std::unordered_map<int, std::string> &ruom = uom; |
3997383b | 106 | // { dg-final { regexp-test ruom {std::(__debug::)?unordered_map with 2 elements = {\[3\] = "seven", \[5\] = "three"}} } } |
c77efe8f | 107 | |
d25b1e3a TT |
108 | std::unordered_multimap<int, std::string> uomm; |
109 | uomm.insert(std::pair<int, std::string> (5, "three")); | |
110 | uomm.insert(std::pair<int, std::string> (5, "seven")); | |
3997383b | 111 | // { dg-final { regexp-test uomm {std::(__debug::)?unordered_multimap with 2 elements = {\[5\] = "seven", \[5\] = "three"}} } } |
c77efe8f | 112 | std::unordered_multimap<int, std::string> &ruomm = uomm; |
3997383b | 113 | // { dg-final { regexp-test ruomm {std::(__debug::)?unordered_multimap with 2 elements = {\[5\] = "seven", \[5\] = "three"}} } } |
d25b1e3a TT |
114 | |
115 | std::unordered_set<int> uos; | |
116 | uos.insert(5); | |
3997383b | 117 | // { dg-final { regexp-test uos {std::(__debug::)?unordered_set with 1 element = {\[0\] = 5}} } } |
c77efe8f | 118 | std::unordered_set<int> &ruos = uos; |
3997383b | 119 | // { dg-final { regexp-test ruos {std::(__debug::)?unordered_set with 1 element = {\[0\] = 5}} } } |
d25b1e3a TT |
120 | |
121 | std::unordered_multiset<int> uoms; | |
122 | uoms.insert(5); | |
3997383b | 123 | // { dg-final { regexp-test uoms {std::(__debug::)?unordered_multiset with 1 element = {\[0\] = 5}} } } |
c77efe8f | 124 | std::unordered_multiset<int> &ruoms = uoms; |
3997383b | 125 | // { dg-final { regexp-test ruoms {std::(__debug::)?unordered_multiset with 1 element = {\[0\] = 5}} } } |
d25b1e3a | 126 | |
c4269a63 TT |
127 | std::unique_ptr<datum> uptr (new datum); |
128 | uptr->s = "hi bob"; | |
129 | uptr->i = 23; | |
d2dfcf82 | 130 | // { dg-final { regexp-test uptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } } |
c77efe8f | 131 | std::unique_ptr<datum> &ruptr = uptr; |
d2dfcf82 | 132 | // { dg-final { regexp-test ruptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } } |
c4269a63 | 133 | |
8273aa77 JW |
134 | using data = datum[]; |
135 | std::unique_ptr<data> arrptr (new datum[2]); | |
136 | // { dg-final { regexp-test arrptr {std::unique_ptr.datum \[\]. = {get\(\) = 0x.*}} } } | |
137 | std::unique_ptr<data>& rarrptr = arrptr; | |
138 | // { dg-final { regexp-test rarrptr {std::unique_ptr.datum \[\]. = {get\(\) = 0x.*}} } } | |
139 | ||
066f9ea2 JW |
140 | struct Deleter |
141 | { | |
142 | int deleter_member = -1; | |
143 | using pointer = __gnu_test::NullablePointer<void>; | |
144 | void operator()(pointer) const noexcept { } | |
145 | }; | |
146 | static_assert( !std::is_empty<Deleter>(), "Deleter is not empty" ); | |
147 | static_assert( std::is_empty<Deleter::pointer>(), "but pointer is empty" ); | |
148 | ||
e25f488d JW |
149 | std::unique_ptr<int, Deleter> empty_ptr; |
150 | // { dg-final { note-test empty_ptr {std::unique_ptr<int> = {get() = {<No data fields>}}} } } | |
151 | std::unique_ptr<int, Deleter>& rempty_ptr = empty_ptr; | |
152 | // { dg-final { note-test rempty_ptr {std::unique_ptr<int> = {get() = {<No data fields>}}} } } | |
153 | ||
c77efe8f | 154 | ExTuple tpl(6,7); |
d2dfcf82 | 155 | // { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } } |
c77efe8f | 156 | ExTuple &rtpl = tpl; |
d2dfcf82 | 157 | // { dg-final { note-test rtpl {std::tuple containing = {[1] = 6, [2] = 7}} } } |
8dfb08ab JW |
158 | placeholder(""); // Mark SPOT |
159 | use(efl); | |
160 | use(fl); | |
161 | use(eum); | |
162 | use(eumm); | |
163 | use(eus); | |
164 | use(eums); | |
c4269a63 TT |
165 | use(uoms); |
166 | use(uptr->s); | |
8273aa77 | 167 | use(arrptr[0].s); |
8dfb08ab | 168 | |
af583c44 | 169 | std::cout << "\n"; |
8dfb08ab JW |
170 | return 0; |
171 | } | |
172 | ||
173 | // { dg-final { gdb-test SPOT } } |