PR libstdc++/65229 fix pretty printer for std::bitset<0>
[official-gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / simple.cc
blob088c65dfe48456721d7f957297ede377bdc6306d
1 // If you modify this, please update simple11.cc and debug.cc as well.
3 // { dg-do run }
4 // { dg-options "-g -O0 -std=gnu++98" }
5 // { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }
7 // Copyright (C) 2011-2018 Free Software Foundation, Inc.
8 //
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the
11 // terms of the GNU General Public License as published by the
12 // Free Software Foundation; either version 3, or (at your option)
13 // any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License along
21 // with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
24 // Type printers only recognize the old std::string for now.
25 #define _GLIBCXX_USE_CXX11_ABI 0
27 #include <string>
28 #include <deque>
29 #include <bitset>
30 #include <iostream>
31 #include <list>
32 #include <map>
33 #include <set>
34 #include <vector>
35 #include <ext/slist>
37 int
38 main()
40 std::string tem;
41 std::string str = "zardoz";
42 // { dg-final { note-test str "\"zardoz\"" } }
44 // PR 65229
45 std::bitset<0> bs0;
46 // { dg-final { note-test bs0 {std::bitset} } }
48 std::bitset<10> bs;
49 bs[0] = 1;
50 bs[5] = 1;
51 bs[7] = 1;
52 // { dg-final { note-test bs {std::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
54 std::deque<std::string> deq;
55 deq.push_back("one");
56 deq.push_back("two");
57 // { dg-final { note-test deq {std::deque with 2 elements = {"one", "two"}} } }
59 std::deque<int>::iterator deqiter0;
60 // { dg-final { note-test deqiter0 {non-dereferenceable iterator for std::deque} } }
62 std::deque<std::string>::iterator deqiter = deq.begin();
63 // { dg-final { note-test deqiter {"one"} } }
65 std::list<std::string> lst;
66 lst.push_back("one");
67 lst.push_back("two");
68 // { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } }
70 std::list<int>::iterator lstiter0;
71 // { dg-final { note-test lstiter0 {non-dereferenceable iterator for std::list} } }
73 std::list<std::string>::iterator lstiter = lst.begin();
74 tem = *lstiter;
75 // { dg-final { note-test lstiter {"one"}} }
77 std::list<std::string>::const_iterator lstciter = lst.begin();
78 tem = *lstciter;
79 // { dg-final { note-test lstciter {"one"}} }
81 std::map<std::string, int> mp;
82 mp["zardoz"] = 23;
83 // { dg-final { note-test mp {std::map with 1 element = {["zardoz"] = 23}} } }
85 std::map<std::string, int>::iterator mpiter = mp.begin();
86 // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
88 std::map<std::string, int>::iterator mpiter0;
89 // { dg-final { note-test mpiter0 {non-dereferenceable iterator for associative container} } }
91 // PR 67440
92 std::set<int> intset;
93 intset.insert(2);
94 intset.insert(3);
95 const std::set<int> const_intset = intset;
96 // { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } }
98 std::set<std::string> sp;
99 sp.insert("clownfish");
100 sp.insert("barrel");
101 // { dg-final { note-test sp {std::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
103 std::set<std::string>::const_iterator spciter = sp.begin();
104 // { dg-final { note-test spciter {"barrel"} } }
106 std::set<int>::iterator spiter0;
107 // { dg-final { note-test spiter0 {non-dereferenceable iterator for associative container} } }
109 std::vector<int> v;
110 v.push_back(1);
111 v.push_back(2);
112 v.erase(v.begin());
113 // { dg-final { note-test v {std::vector of length 1, capacity 2 = {2}} } }
114 std::vector<int>::iterator viter3 = v.begin();
115 // { dg-final { note-test viter3 {2} } }
117 std::vector<int>::iterator viter0;
118 // { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
120 __gnu_cxx::slist<int> sll;
121 sll.push_front(23);
122 sll.push_front(47);
123 // { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }
125 __gnu_cxx::slist<int>::iterator slliter = sll.begin();
126 // { dg-final { note-test slliter {47} } }
128 __gnu_cxx::slist<int>::iterator slliter0;
129 // { dg-final { note-test slliter0 {non-dereferenceable iterator for __gnu_cxx::slist} } }
131 std::cout << "\n";
132 return 0; // Mark SPOT
135 // { dg-final { gdb-test SPOT } }