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