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