1 // { dg-do run { target c++11 } }
2 // { dg-options "-g -O0" }
3 
4 // Copyright (C) 2011-2020 Free Software Foundation, Inc.
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 // GDB can't find global variables using the abi_tag attribute.
22 // https://sourceware.org/bugzilla/show_bug.cgi?id=19436
23 #define _GLIBCXX_USE_CXX11_ABI 0
24 
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>
38 
39 template<class T>
40 void
placeholder(const T * s)41 placeholder(const T *s)
42 {
43   std::cout << (void *) s;
44 }
45 
46 template<class T>
47 struct holder
48 {
49   T *f;
50 };
51 
52 // This test is written in a somewhat funny way.
53 // Each type under test is used twice: first, to form a pointer type,
54 // and second, as a template parameter.  This is done to work around
55 // apparent GCC oddities.  The pointer type is needed to ensure that
56 // the typedef in question ends up in the debuginfo; while the
57 // template type is used to ensure that a typedef-less variant is
58 // presented to gdb.
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-regexp-test seq1_holder "holder<std::(__debug::)?vector<std::(__debug::)?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-regexp-test seq2_holder "holder<std::(__debug::)?list<std::(__debug::)?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-regexp-test assoc1_holder "holder<std::(__debug::)?map<int, std::(__debug::)?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-regexp-test assoc2_holder "holder<std::(__debug::)?multimap<int, std::(__debug::)?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-regexp-test unord1_holder "holder<std::(__debug::)?unordered_map<int, std::(__debug::)?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-regexp-test unord2_holder "holder<std::(__debug::)?unordered_multimap<int, std::(__debug::)?unordered_multiset<int>> >" } }
189 
190 
191 int
main()192 main()
193 {
194   placeholder(&ios_ptr);		// Mark SPOT
195   placeholder(&ios_holder);
196   placeholder(&string_ptr);
197   placeholder(&string_holder);
198   placeholder(&streambuf_ptr);
199   placeholder(&streambuf_holder);
200   placeholder(&istream_ptr);
201   placeholder(&istream_holder);
202   placeholder(&ostream_ptr);
203   placeholder(&ostream_holder);
204   placeholder(&iostream_ptr);
205   placeholder(&iostream_holder);
206   placeholder(&stringbuf_ptr);
207   placeholder(&stringbuf_holder);
208   placeholder(&istringstream_ptr);
209   placeholder(&istringstream_holder);
210   placeholder(&ostringstream_ptr);
211   placeholder(&ostringstream_holder);
212   placeholder(&stringstream_ptr);
213   placeholder(&stringstream_holder);
214   placeholder(&filebuf_ptr);
215   placeholder(&filebuf_holder);
216   placeholder(&ifstream_ptr);
217   placeholder(&ifstream_holder);
218   placeholder(&ofstream_ptr);
219   placeholder(&ofstream_holder);
220   placeholder(&fstream_ptr);
221   placeholder(&fstream_holder);
222   placeholder(&streampos_ptr);
223   placeholder(&streampos_holder);
224   placeholder(&regex_ptr);
225   placeholder(&regex_holder);
226   placeholder(&csub_match_ptr);
227   placeholder(&csub_match_holder);
228   placeholder(&ssub_match_ptr);
229   placeholder(&ssub_match_holder);
230   placeholder(&cmatch_ptr);
231   placeholder(&cmatch_holder);
232   placeholder(&smatch_ptr);
233   placeholder(&smatch_holder);
234   placeholder(&cregex_iterator_ptr);
235   placeholder(&cregex_iterator_holder);
236   placeholder(&sregex_iterator_ptr);
237   placeholder(&sregex_iterator_holder);
238   placeholder(&cregex_token_iterator_ptr);
239   placeholder(&cregex_token_iterator_holder);
240   placeholder(&sregex_token_iterator_ptr);
241   placeholder(&sregex_token_iterator_holder);
242   placeholder(&u16string_ptr);
243   placeholder(&u16string_holder);
244   placeholder(&u32string_ptr);
245   placeholder(&u32string_holder);
246   placeholder(&minstd_rand0_ptr);
247   placeholder(&minstd_rand0_holder);
248   placeholder(&minstd_rand_ptr);
249   placeholder(&minstd_rand_holder);
250   placeholder(&mt19937_ptr);
251   placeholder(&mt19937_holder);
252   placeholder(&mt19937_64_ptr);
253   placeholder(&mt19937_64_holder);
254   placeholder(&ranlux24_base_ptr);
255   placeholder(&ranlux24_base_holder);
256   placeholder(&ranlux48_base_ptr);
257   placeholder(&ranlux48_base_holder);
258   placeholder(&ranlux24_ptr);
259   placeholder(&ranlux24_holder);
260   placeholder(&ranlux48_ptr);
261   placeholder(&ranlux48_holder);
262   placeholder(&knuth_b_ptr);
263   placeholder(&knuth_b_holder);
264   placeholder(&seq1_ptr);
265   placeholder(&seq1_holder);
266   placeholder(&seq2_ptr);
267   placeholder(&seq2_holder);
268   placeholder(&assoc1_ptr);
269   placeholder(&assoc1_holder);
270   placeholder(&assoc2_ptr);
271   placeholder(&assoc2_holder);
272   placeholder(&unord1_ptr);
273   placeholder(&unord1_holder);
274   placeholder(&unord2_ptr);
275   placeholder(&unord2_holder);
276 
277   std::cout << "\n";
278   return 0;
279 }
280 
281 // { dg-final { gdb-test SPOT } }
282