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