2018-08-31 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / simple.cc
blob1ed8184a853cd0b8309e0dc4f7957e5cfa6765ad
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 std::bitset<10> bs;
45 bs[0] = 1;
46 bs[5] = 1;
47 bs[7] = 1;
48 // { dg-final { note-test bs {std::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
50 std::deque<std::string> deq;
51 deq.push_back("one");
52 deq.push_back("two");
53 // { dg-final { note-test deq {std::deque with 2 elements = {"one", "two"}} } }
55 std::deque<int>::iterator deqiter0;
56 // { dg-final { note-test deqiter0 {non-dereferenceable iterator for std::deque} } }
58 std::deque<std::string>::iterator deqiter = deq.begin();
59 // { dg-final { note-test deqiter {"one"} } }
61 std::list<std::string> lst;
62 lst.push_back("one");
63 lst.push_back("two");
64 // { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } }
66 std::list<int>::iterator lstiter0;
67 // { dg-final { note-test lstiter0 {non-dereferenceable iterator for std::list} } }
69 std::list<std::string>::iterator lstiter = lst.begin();
70 tem = *lstiter;
71 // { dg-final { note-test lstiter {"one"}} }
73 std::list<std::string>::const_iterator lstciter = lst.begin();
74 tem = *lstciter;
75 // { dg-final { note-test lstciter {"one"}} }
77 std::map<std::string, int> mp;
78 mp["zardoz"] = 23;
79 // { dg-final { note-test mp {std::map with 1 element = {["zardoz"] = 23}} } }
81 std::map<std::string, int>::iterator mpiter = mp.begin();
82 // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
84 std::map<std::string, int>::iterator mpiter0;
85 // { dg-final { note-test mpiter0 {non-dereferenceable iterator for associative container} } }
87 // PR 67440
88 std::set<int> intset;
89 intset.insert(2);
90 intset.insert(3);
91 const std::set<int> const_intset = intset;
92 // { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } }
94 std::set<std::string> sp;
95 sp.insert("clownfish");
96 sp.insert("barrel");
97 // { dg-final { note-test sp {std::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
99 std::set<std::string>::const_iterator spciter = sp.begin();
100 // { dg-final { note-test spciter {"barrel"} } }
102 std::set<int>::iterator spiter0;
103 // { dg-final { note-test spiter0 {non-dereferenceable iterator for associative container} } }
105 std::vector<int> v;
106 v.push_back(1);
107 v.push_back(2);
108 v.erase(v.begin());
109 // { dg-final { note-test v {std::vector of length 1, capacity 2 = {2}} } }
110 std::vector<int>::iterator viter3 = v.begin();
111 // { dg-final { note-test viter3 {2} } }
113 std::vector<int>::iterator viter0;
114 // { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
116 __gnu_cxx::slist<int> sll;
117 sll.push_front(23);
118 sll.push_front(47);
119 // { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }
121 __gnu_cxx::slist<int>::iterator slliter = sll.begin();
122 // { dg-final { note-test slliter {47} } }
124 __gnu_cxx::slist<int>::iterator slliter0;
125 // { dg-final { note-test slliter0 {non-dereferenceable iterator for __gnu_cxx::slist} } }
127 std::cout << "\n";
128 return 0; // Mark SPOT
131 // { dg-final { gdb-test SPOT } }