]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis2.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / whatis2.cc
CommitLineData
bab0a26d
JW
1// { dg-do run { target c++11 } }
2// { dg-options "-g -O0" }
bab0a26d 3
a945c346 4// Copyright (C) 2011-2024 Free Software Foundation, Inc.
bab0a26d
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 <string>
22#include <iostream>
23#include <regex>
24#include <memory>
25#include <deque>
26#include <forward_list>
27#include <list>
28#include <vector>
29#include <map>
30#include <set>
31#include <unordered_map>
32#include <unordered_set>
33#include <random>
34
35template<class T>
36void
37placeholder(const T *s)
38{
39 std::cout << (void *) s;
40}
41
42template<class T>
43struct holder
44{
45 T *f;
46};
47
48// This test is written in a somewhat funny way.
49// Each type under test is used twice: first, to form a pointer type,
50// and second, as a template parameter. This is done to work around
51// apparent GCC oddities. The pointer type is needed to ensure that
52// the typedef in question ends up in the debuginfo; while the
53// template type is used to ensure that a typedef-less variant is
54// presented to gdb.
55
56int
57main()
58{
59 std::string *string_ptr;
60 holder<std::string> string_holder;
61// { dg-final { whatis-test string_holder "holder<std::string>" } }
62 std::ios *ios_ptr;
63 holder<std::ios> ios_holder;
64// { dg-final { whatis-test ios_holder "holder<std::ios>" } }
65 std::streambuf *streambuf_ptr;
66 holder<std::streambuf> streambuf_holder;
67// { dg-final { whatis-test streambuf_holder "holder<std::streambuf>" } }
68 std::istream *istream_ptr;
69 holder<std::istream> istream_holder;
70// { dg-final { whatis-test istream_holder "holder<std::istream>" } }
71 std::ostream *ostream_ptr;
72 holder<std::ostream> ostream_holder;
73// { dg-final { whatis-test ostream_holder "holder<std::ostream>" } }
74 std::iostream *iostream_ptr;
75 holder<std::iostream> iostream_holder;
76// { dg-final { whatis-test iostream_holder "holder<std::iostream>" } }
77 std::stringbuf *stringbuf_ptr;
78 holder<std::stringbuf> stringbuf_holder;
79// { dg-final { whatis-test stringbuf_holder "holder<std::stringbuf>" } }
80 std::istringstream *istringstream_ptr;
81 holder<std::istringstream> istringstream_holder;
82// { dg-final { whatis-test istringstream_holder "holder<std::istringstream>" } }
83 std::ostringstream *ostringstream_ptr;
84 holder<std::ostringstream> ostringstream_holder;
85// { dg-final { whatis-test ostringstream_holder "holder<std::ostringstream>" } }
86 std::stringstream *stringstream_ptr;
87 holder<std::stringstream> stringstream_holder;
88// { dg-final { whatis-test stringstream_holder "holder<std::stringstream>" } }
89 std::filebuf *filebuf_ptr;
90 holder<std::filebuf> filebuf_holder;
91// { dg-final { whatis-test filebuf_holder "holder<std::filebuf>" } }
92 std::ifstream *ifstream_ptr;
93 holder<std::ifstream> ifstream_holder;
94// { dg-final { whatis-test ifstream_holder "holder<std::ifstream>" } }
95 std::ofstream *ofstream_ptr;
96 holder<std::ofstream> ofstream_holder;
97// { dg-final { whatis-test ofstream_holder "holder<std::ofstream>" } }
98 std::fstream *fstream_ptr;
99 holder<std::fstream> fstream_holder;
100// { dg-final { whatis-test fstream_holder "holder<std::fstream>" } }
101 std::streampos *streampos_ptr;
102 holder<std::streampos> streampos_holder;
103// { dg-final { whatis-test streampos_holder "holder<std::streampos>" } }
104 std::regex *regex_ptr;
105 holder<std::regex> regex_holder;
106// { dg-final { whatis-test regex_holder "holder<std::regex>" } }
107std::csub_match *csub_match_ptr;
108holder<std::csub_match> csub_match_holder;
109// { dg-final { whatis-test csub_match_holder "holder<std::csub_match>" } }
110 std::ssub_match *ssub_match_ptr;
111 holder<std::ssub_match> ssub_match_holder;
112// { dg-final { whatis-test ssub_match_holder "holder<std::ssub_match>" } }
113 std::cmatch *cmatch_ptr;
114 holder<std::cmatch> cmatch_holder;
115// { dg-final { whatis-test cmatch_holder "holder<std::cmatch>" } }
116 std::smatch *smatch_ptr;
117 holder<std::smatch> smatch_holder;
118// { dg-final { whatis-test smatch_holder "holder<std::smatch>" } }
119 std::cregex_iterator *cregex_iterator_ptr;
120 holder<std::cregex_iterator> cregex_iterator_holder;
121// { dg-final { whatis-test cregex_iterator_holder "holder<std::cregex_iterator>" } }
122 std::sregex_iterator *sregex_iterator_ptr;
123 holder<std::sregex_iterator> sregex_iterator_holder;
124// { dg-final { whatis-test sregex_iterator_holder "holder<std::sregex_iterator>" } }
125 std::cregex_token_iterator *cregex_token_iterator_ptr;
126 holder<std::cregex_token_iterator> cregex_token_iterator_holder;
127// { dg-final { whatis-test cregex_token_iterator_holder "holder<std::cregex_token_iterator>" } }
128 std::sregex_token_iterator *sregex_token_iterator_ptr;
129 holder<std::sregex_token_iterator> sregex_token_iterator_holder;
130// { dg-final { whatis-test sregex_token_iterator_holder "holder<std::sregex_token_iterator>" } }
131 std::u16string *u16string_ptr;
132 holder<std::u16string> u16string_holder;
133// { dg-final { whatis-test u16string_holder "holder<std::u16string>" } }
134 std::u32string *u32string_ptr;
135 holder<std::u32string> u32string_holder;
136// { dg-final { whatis-test u32string_holder "holder<std::u32string>" } }
137 std::minstd_rand0 *minstd_rand0_ptr;
138 holder<std::minstd_rand0> minstd_rand0_holder;
139// { dg-final { whatis-test minstd_rand0_holder "holder<std::minstd_rand0>" } }
140 std::minstd_rand *minstd_rand_ptr;
141 holder<std::minstd_rand> minstd_rand_holder;
142// { dg-final { whatis-test minstd_rand_holder "holder<std::minstd_rand>" } }
143 std::mt19937 *mt19937_ptr;
144 holder<std::mt19937> mt19937_holder;
145// { dg-final { whatis-test mt19937_holder "holder<std::mt19937>" } }
146 std::mt19937_64 *mt19937_64_ptr;
147 holder<std::mt19937_64> mt19937_64_holder;
148// { dg-final { whatis-test mt19937_64_holder "holder<std::mt19937_64>" } }
149 std::ranlux24_base *ranlux24_base_ptr;
150 holder<std::ranlux24_base> ranlux24_base_holder;
151// { dg-final { whatis-test ranlux24_base_holder "holder<std::ranlux24_base>" } }
152 std::ranlux48_base *ranlux48_base_ptr;
153 holder<std::ranlux48_base> ranlux48_base_holder;
154// { dg-final { whatis-test ranlux48_base_holder "holder<std::ranlux48_base>" } }
155 std::ranlux24 *ranlux24_ptr;
156 holder<std::ranlux24> ranlux24_holder;
157// { dg-final { whatis-test ranlux24_holder "holder<std::ranlux24>" } }
158 std::ranlux48 *ranlux48_ptr;
159 holder<std::ranlux48> ranlux48_holder;
160// { dg-final { whatis-test ranlux48_holder "holder<std::ranlux48>" } }
161 std::knuth_b *knuth_b_ptr;
162 holder<std::knuth_b> knuth_b_holder;
163// { dg-final { whatis-test knuth_b_holder "holder<std::knuth_b>" } }
164
165 std::vector<std::deque<std::unique_ptr<char>>> *seq1_ptr;
166 holder< std::vector<std::deque<std::unique_ptr<char>>> > seq1_holder;
3997383b 167// { dg-final { whatis-regexp-test seq1_holder "holder<std::(__debug::)?vector<std::(__debug::)?deque<std::unique_ptr<char>>> >" } }
bab0a26d
JW
168
169 std::list<std::forward_list<std::unique_ptr<char>>> *seq2_ptr;
170 holder< std::list<std::forward_list<std::unique_ptr<char>>> > seq2_holder;
3997383b 171// { dg-final { whatis-regexp-test seq2_holder "holder<std::(__debug::)?list<std::(__debug::)?forward_list<std::unique_ptr<char>>> >" } }
bab0a26d
JW
172
173 std::map<int, std::set<int>> *assoc1_ptr;
174 holder< std::map<int, std::set<int>> > assoc1_holder;
3997383b 175// { dg-final { whatis-regexp-test assoc1_holder "holder<std::(__debug::)?map<int, std::(__debug::)?set<int>> >" } }
bab0a26d
JW
176
177 std::multimap<int, std::multiset<int>> *assoc2_ptr;
178 holder< std::multimap<int, std::multiset<int>> > assoc2_holder;
3997383b 179// { dg-final { whatis-regexp-test assoc2_holder "holder<std::(__debug::)?multimap<int, std::(__debug::)?multiset<int>> >" } }
bab0a26d
JW
180
181 std::unordered_map<int, std::unordered_set<int>> *unord1_ptr;
182 holder< std::unordered_map<int, std::unordered_set<int>> > unord1_holder;
3997383b 183// { dg-final { whatis-regexp-test unord1_holder "holder<std::(__debug::)?unordered_map<int, std::(__debug::)?unordered_set<int>> >" } }
bab0a26d
JW
184
185 std::unordered_multimap<int, std::unordered_multiset<int>> *unord2_ptr;
186 holder< std::unordered_multimap<int, std::unordered_multiset<int>> > unord2_holder;
3997383b 187// { dg-final { whatis-regexp-test unord2_holder "holder<std::(__debug::)?unordered_multimap<int, std::(__debug::)?unordered_multiset<int>> >" } }
bab0a26d
JW
188
189
190 placeholder(&ios_ptr); // Mark SPOT
191 placeholder(&ios_holder);
192 placeholder(&string_ptr);
193 placeholder(&string_holder);
194 placeholder(&streambuf_ptr);
195 placeholder(&streambuf_holder);
196 placeholder(&istream_ptr);
197 placeholder(&istream_holder);
198 placeholder(&ostream_ptr);
199 placeholder(&ostream_holder);
200 placeholder(&iostream_ptr);
201 placeholder(&iostream_holder);
202 placeholder(&stringbuf_ptr);
203 placeholder(&stringbuf_holder);
204 placeholder(&istringstream_ptr);
205 placeholder(&istringstream_holder);
206 placeholder(&ostringstream_ptr);
207 placeholder(&ostringstream_holder);
208 placeholder(&stringstream_ptr);
209 placeholder(&stringstream_holder);
210 placeholder(&filebuf_ptr);
211 placeholder(&filebuf_holder);
212 placeholder(&ifstream_ptr);
213 placeholder(&ifstream_holder);
214 placeholder(&ofstream_ptr);
215 placeholder(&ofstream_holder);
216 placeholder(&fstream_ptr);
217 placeholder(&fstream_holder);
218 placeholder(&streampos_ptr);
219 placeholder(&streampos_holder);
220 placeholder(&regex_ptr);
221 placeholder(&regex_holder);
222 placeholder(&csub_match_ptr);
223 placeholder(&csub_match_holder);
224 placeholder(&ssub_match_ptr);
225 placeholder(&ssub_match_holder);
226 placeholder(&cmatch_ptr);
227 placeholder(&cmatch_holder);
228 placeholder(&smatch_ptr);
229 placeholder(&smatch_holder);
230 placeholder(&cregex_iterator_ptr);
231 placeholder(&cregex_iterator_holder);
232 placeholder(&sregex_iterator_ptr);
233 placeholder(&sregex_iterator_holder);
234 placeholder(&cregex_token_iterator_ptr);
235 placeholder(&cregex_token_iterator_holder);
236 placeholder(&sregex_token_iterator_ptr);
237 placeholder(&sregex_token_iterator_holder);
238 placeholder(&u16string_ptr);
239 placeholder(&u16string_holder);
240 placeholder(&u32string_ptr);
241 placeholder(&u32string_holder);
242 placeholder(&minstd_rand0_ptr);
243 placeholder(&minstd_rand0_holder);
244 placeholder(&minstd_rand_ptr);
245 placeholder(&minstd_rand_holder);
246 placeholder(&mt19937_ptr);
247 placeholder(&mt19937_holder);
248 placeholder(&mt19937_64_ptr);
249 placeholder(&mt19937_64_holder);
250 placeholder(&ranlux24_base_ptr);
251 placeholder(&ranlux24_base_holder);
252 placeholder(&ranlux48_base_ptr);
253 placeholder(&ranlux48_base_holder);
254 placeholder(&ranlux24_ptr);
255 placeholder(&ranlux24_holder);
256 placeholder(&ranlux48_ptr);
257 placeholder(&ranlux48_holder);
258 placeholder(&knuth_b_ptr);
259 placeholder(&knuth_b_holder);
260 placeholder(&seq1_ptr);
261 placeholder(&seq1_holder);
262 placeholder(&seq2_ptr);
263 placeholder(&seq2_holder);
264 placeholder(&assoc1_ptr);
265 placeholder(&assoc1_holder);
266 placeholder(&assoc2_ptr);
267 placeholder(&assoc2_holder);
268 placeholder(&unord1_ptr);
269 placeholder(&unord1_holder);
270 placeholder(&unord2_ptr);
271 placeholder(&unord2_holder);
272
273 std::cout << "\n";
274 return 0;
275}
276
277// { dg-final { gdb-test SPOT } }