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