summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc
blob: 0f9c2fbbcd94ea1fb116aaccfd788d3636136366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
// { dg-do run }
// { dg-options "-g -O0 -std=gnu++11" }

// Copyright (C) 2011-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.

// Type printers only recognize the old std::string for now.
#define _GLIBCXX_USE_CXX11_ABI 0

#include <string>
#include <iostream>
#include <regex>
#include <memory>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

template<class T>
void
placeholder(const T *s)
{
  std::cout << (void *) s;
}

template<class T>
struct holder
{
  T *f;
};

typedef std::basic_string<unsigned char> ustring;

// This test is written in a somewhat funny way.
// Each type under test is used twice: first, to form a pointer type,
// and second, as a template parameter.  This is done to work around
// apparent GCC oddities.  The pointer type is needed to ensure that
// the typedef in question ends up in the debuginfo; while the
// template type is used to ensure that a typedef-less variant is
// presented to gdb.

std::string *string_ptr;
holder<std::string> string_holder;
// { dg-final { whatis-test string_holder "holder<std::string>" } }
std::ios *ios_ptr;
holder<std::ios> ios_holder;
// { dg-final { whatis-test ios_holder "holder<std::ios>" } }
std::streambuf *streambuf_ptr;
holder<std::streambuf> streambuf_holder;
// { dg-final { whatis-test streambuf_holder "holder<std::streambuf>" } }
std::istream *istream_ptr;
holder<std::istream> istream_holder;
// { dg-final { whatis-test istream_holder "holder<std::istream>" } }
std::ostream *ostream_ptr;
holder<std::ostream> ostream_holder;
// { dg-final { whatis-test ostream_holder "holder<std::ostream>" } }
std::iostream *iostream_ptr;
holder<std::iostream> iostream_holder;
// { dg-final { whatis-test iostream_holder "holder<std::iostream>" } }
std::stringbuf *stringbuf_ptr;
holder<std::stringbuf> stringbuf_holder;
// { dg-final { whatis-test stringbuf_holder "holder<std::stringbuf>" } }
std::istringstream *istringstream_ptr;
holder<std::istringstream> istringstream_holder;
// { dg-final { whatis-test istringstream_holder "holder<std::istringstream>" } }
std::ostringstream *ostringstream_ptr;
holder<std::ostringstream> ostringstream_holder;
// { dg-final { whatis-test ostringstream_holder "holder<std::ostringstream>" } }
std::stringstream *stringstream_ptr;
holder<std::stringstream> stringstream_holder;
// { dg-final { whatis-test stringstream_holder "holder<std::stringstream>" } }
std::filebuf *filebuf_ptr;
holder<std::filebuf> filebuf_holder;
// { dg-final { whatis-test filebuf_holder "holder<std::filebuf>" } }
std::ifstream *ifstream_ptr;
holder<std::ifstream> ifstream_holder;
// { dg-final { whatis-test ifstream_holder "holder<std::ifstream>" } }
std::ofstream *ofstream_ptr;
holder<std::ofstream> ofstream_holder;
// { dg-final { whatis-test ofstream_holder "holder<std::ofstream>" } }
std::fstream *fstream_ptr;
holder<std::fstream> fstream_holder;
// { dg-final { whatis-test fstream_holder "holder<std::fstream>" } }
std::streampos *streampos_ptr;
holder<std::streampos> streampos_holder;
// { dg-final { whatis-test streampos_holder "holder<std::streampos>" } }
std::regex *regex_ptr;
holder<std::regex> regex_holder;
// { dg-final { whatis-test regex_holder "holder<std::regex>" } }
std::csub_match *csub_match_ptr;
holder<std::csub_match> csub_match_holder;
// { dg-final { whatis-test csub_match_holder "holder<std::csub_match>" } }
std::ssub_match *ssub_match_ptr;
holder<std::ssub_match> ssub_match_holder;
// { dg-final { whatis-test ssub_match_holder "holder<std::ssub_match>" } }
std::cmatch *cmatch_ptr;
holder<std::cmatch> cmatch_holder;
// { dg-final { whatis-test cmatch_holder "holder<std::cmatch>" } }
std::smatch *smatch_ptr;
holder<std::smatch> smatch_holder;
// { dg-final { whatis-test smatch_holder "holder<std::smatch>" } }
std::cregex_iterator *cregex_iterator_ptr;
holder<std::cregex_iterator> cregex_iterator_holder;
// { dg-final { whatis-test cregex_iterator_holder "holder<std::cregex_iterator>" } }
std::sregex_iterator *sregex_iterator_ptr;
holder<std::sregex_iterator> sregex_iterator_holder;
// { dg-final { whatis-test sregex_iterator_holder "holder<std::sregex_iterator>" } }
std::cregex_token_iterator *cregex_token_iterator_ptr;
holder<std::cregex_token_iterator> cregex_token_iterator_holder;
// { dg-final { whatis-test cregex_token_iterator_holder "holder<std::cregex_token_iterator>" } }
std::sregex_token_iterator *sregex_token_iterator_ptr;
holder<std::sregex_token_iterator> sregex_token_iterator_holder;
// { dg-final { whatis-test sregex_token_iterator_holder "holder<std::sregex_token_iterator>" } }
std::u16string *u16string_ptr;
holder<std::u16string> u16string_holder;
// { dg-final { whatis-test u16string_holder "holder<std::u16string>" } }
std::u32string *u32string_ptr;
holder<std::u32string> u32string_holder;
// { dg-final { whatis-test u32string_holder "holder<std::u32string>" } }
std::minstd_rand0 *minstd_rand0_ptr;
holder<std::minstd_rand0> minstd_rand0_holder;
// { dg-final { whatis-test minstd_rand0_holder "holder<std::minstd_rand0>" } }
std::minstd_rand *minstd_rand_ptr;
holder<std::minstd_rand> minstd_rand_holder;
// { dg-final { whatis-test minstd_rand_holder "holder<std::minstd_rand>" } }
std::mt19937 *mt19937_ptr;
holder<std::mt19937> mt19937_holder;
// { dg-final { whatis-test mt19937_holder "holder<std::mt19937>" } }
std::mt19937_64 *mt19937_64_ptr;
holder<std::mt19937_64> mt19937_64_holder;
// { dg-final { whatis-test mt19937_64_holder "holder<std::mt19937_64>" } }
std::ranlux24_base *ranlux24_base_ptr;
holder<std::ranlux24_base> ranlux24_base_holder;
// { dg-final { whatis-test ranlux24_base_holder "holder<std::ranlux24_base>" } }
std::ranlux48_base *ranlux48_base_ptr;
holder<std::ranlux48_base> ranlux48_base_holder;
// { dg-final { whatis-test ranlux48_base_holder "holder<std::ranlux48_base>" } }
std::ranlux24 *ranlux24_ptr;
holder<std::ranlux24> ranlux24_holder;
// { dg-final { whatis-test ranlux24_holder "holder<std::ranlux24>" } }
std::ranlux48 *ranlux48_ptr;
holder<std::ranlux48> ranlux48_holder;
// { dg-final { whatis-test ranlux48_holder "holder<std::ranlux48>" } }
std::knuth_b *knuth_b_ptr;
holder<std::knuth_b> knuth_b_holder;
// { dg-final { whatis-test knuth_b_holder "holder<std::knuth_b>" } }

ustring *ustring_ptr;
holder<ustring> ustring_holder;
// { dg-final { whatis-test ustring_holder "holder<std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> > >" } }

std::basic_string<signed char> *sstring_ptr;
holder< std::basic_string<signed char> > sstring_holder;
// { dg-final { whatis-test sstring_holder "holder<std::basic_string<signed char, std::char_traits<signed char>, std::allocator<signed char> > >" } }

std::vector<std::deque<std::unique_ptr<char>>> *seq1_ptr;
holder< std::vector<std::deque<std::unique_ptr<char>>> > seq1_holder;
// { dg-final { whatis-test seq1_holder "holder<std::vector<std::deque<std::unique_ptr<char>>> >" } }

std::list<std::forward_list<std::unique_ptr<char>>> *seq2_ptr;
holder< std::list<std::forward_list<std::unique_ptr<char>>> > seq2_holder;
// { dg-final { whatis-test seq2_holder "holder<std::list<std::forward_list<std::unique_ptr<char>>> >" } }

std::map<int, std::set<int>> *assoc1_ptr;
holder< std::map<int, std::set<int>> > assoc1_holder;
// { dg-final { whatis-test assoc1_holder "holder<std::map<int, std::set<int>> >" } }

std::multimap<int, std::multiset<int>> *assoc2_ptr;
holder< std::multimap<int, std::multiset<int>> > assoc2_holder;
// { dg-final { whatis-test assoc2_holder "holder<std::multimap<int, std::multiset<int>> >" } }

std::unordered_map<int, std::unordered_set<int>> *unord1_ptr;
holder< std::unordered_map<int, std::unordered_set<int>> > unord1_holder;
// { dg-final { whatis-test unord1_holder "holder<std::unordered_map<int, std::unordered_set<int>> >" } }

std::unordered_multimap<int, std::unordered_multiset<int>> *unord2_ptr;
holder< std::unordered_multimap<int, std::unordered_multiset<int>> > unord2_holder;
// { dg-final { whatis-test unord2_holder "holder<std::unordered_multimap<int, std::unordered_multiset<int>> >" } }


int
main()
{
  placeholder(&ios_ptr);		// Mark SPOT
  placeholder(&ios_holder);
  placeholder(&string_ptr);
  placeholder(&string_holder);
  placeholder(&streambuf_ptr);
  placeholder(&streambuf_holder);
  placeholder(&istream_ptr);
  placeholder(&istream_holder);
  placeholder(&ostream_ptr);
  placeholder(&ostream_holder);
  placeholder(&iostream_ptr);
  placeholder(&iostream_holder);
  placeholder(&stringbuf_ptr);
  placeholder(&stringbuf_holder);
  placeholder(&istringstream_ptr);
  placeholder(&istringstream_holder);
  placeholder(&ostringstream_ptr);
  placeholder(&ostringstream_holder);
  placeholder(&stringstream_ptr);
  placeholder(&stringstream_holder);
  placeholder(&filebuf_ptr);
  placeholder(&filebuf_holder);
  placeholder(&ifstream_ptr);
  placeholder(&ifstream_holder);
  placeholder(&ofstream_ptr);
  placeholder(&ofstream_holder);
  placeholder(&fstream_ptr);
  placeholder(&fstream_holder);
  placeholder(&streampos_ptr);
  placeholder(&streampos_holder);
  placeholder(&regex_ptr);
  placeholder(&regex_holder);
  placeholder(&csub_match_ptr);
  placeholder(&csub_match_holder);
  placeholder(&ssub_match_ptr);
  placeholder(&ssub_match_holder);
  placeholder(&cmatch_ptr);
  placeholder(&cmatch_holder);
  placeholder(&smatch_ptr);
  placeholder(&smatch_holder);
  placeholder(&cregex_iterator_ptr);
  placeholder(&cregex_iterator_holder);
  placeholder(&sregex_iterator_ptr);
  placeholder(&sregex_iterator_holder);
  placeholder(&cregex_token_iterator_ptr);
  placeholder(&cregex_token_iterator_holder);
  placeholder(&sregex_token_iterator_ptr);
  placeholder(&sregex_token_iterator_holder);
  placeholder(&u16string_ptr);
  placeholder(&u16string_holder);
  placeholder(&u32string_ptr);
  placeholder(&u32string_holder);
  placeholder(&minstd_rand0_ptr);
  placeholder(&minstd_rand0_holder);
  placeholder(&minstd_rand_ptr);
  placeholder(&minstd_rand_holder);
  placeholder(&mt19937_ptr);
  placeholder(&mt19937_holder);
  placeholder(&mt19937_64_ptr);
  placeholder(&mt19937_64_holder);
  placeholder(&ranlux24_base_ptr);
  placeholder(&ranlux24_base_holder);
  placeholder(&ranlux48_base_ptr);
  placeholder(&ranlux48_base_holder);
  placeholder(&ranlux24_ptr);
  placeholder(&ranlux24_holder);
  placeholder(&ranlux48_ptr);
  placeholder(&ranlux48_holder);
  placeholder(&knuth_b_ptr);
  placeholder(&knuth_b_holder);
  placeholder(&ustring_ptr);
  placeholder(&ustring_holder);
  placeholder(&sstring_ptr);
  placeholder(&sstring_holder);
  placeholder(&seq1_ptr);
  placeholder(&seq1_holder);
  placeholder(&seq2_ptr);
  placeholder(&seq2_holder);
  placeholder(&assoc1_ptr);
  placeholder(&assoc1_holder);
  placeholder(&assoc2_ptr);
  placeholder(&assoc2_holder);
  placeholder(&unord1_ptr);
  placeholder(&unord1_holder);
  placeholder(&unord2_ptr);
  placeholder(&unord2_holder);

  return 0;
}

// { dg-final { gdb-test SPOT } }