]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/libstdc++-prettyprinters/debug.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / debug.cc
1 // { dg-do run }
2 // { dg-options "-g -O0 -std=gnu++98" }
3 // { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }
4
5 // Copyright (C) 2011-2019 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.
12
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.
17
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/>.
21
22 #ifndef _GLIBCXX_DEBUG
23 # define _GLIBCXX_DEBUG
24 #endif
25
26 #include <string>
27 #include <deque>
28 #include <bitset>
29 #include <iostream>
30 #include <list>
31 #include <map>
32 #include <set>
33 #include <vector>
34 #include <ext/slist>
35
36 int
37 main()
38 {
39 std::string tem;
40 std::string str = "zardoz";
41 // { dg-final { note-test str "\"zardoz\"" } }
42
43 std::bitset<10> bs;
44 bs[0] = 1;
45 bs[5] = 1;
46 bs[7] = 1;
47 // { dg-final { note-test bs {std::__debug::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
48
49 std::deque<std::string> deq;
50 deq.push_back("one");
51 deq.push_back("two");
52 // { dg-final { note-test deq {std::__debug::deque with 2 elements = {"one", "two"}} } }
53
54 std::deque<std::string>::iterator deqiter = deq.begin();
55 // { dg-final { note-test deqiter {"one"} } }
56
57 std::list<std::string> lst;
58 lst.push_back("one");
59 lst.push_back("two");
60 // { dg-final { note-test lst {std::__debug::list = {[0] = "one", [1] = "two"}} } }
61
62 std::list<std::string>::iterator lstiter = lst.begin();
63 tem = *lstiter;
64 // { dg-final { note-test lstiter {"one"}} }
65
66 std::list<std::string>::const_iterator lstciter = lst.begin();
67 tem = *lstciter;
68 // { dg-final { note-test lstciter {"one"}} }
69
70 std::map<std::string, int> mp;
71 mp["zardoz"] = 23;
72 // { dg-final { note-test mp {std::__debug::map with 1 element = {["zardoz"] = 23}} } }
73
74 std::map<std::string, int>::iterator mpiter = mp.begin();
75 // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
76
77 // PR 67440
78 std::set<int> intset;
79 intset.insert(2);
80 intset.insert(3);
81 const std::set<int> const_intset = intset;
82 // { dg-final { note-test const_intset {std::__debug::set with 2 elements = {[0] = 2, [1] = 3}} } }
83
84 std::set<std::string> sp;
85 sp.insert("clownfish");
86 sp.insert("barrel");
87 // { dg-final { note-test sp {std::__debug::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
88
89 std::set<std::string>::const_iterator spciter = sp.begin();
90 // { dg-final { note-test spciter {"barrel"} } }
91
92 __gnu_cxx::slist<int> sll;
93 sll.push_front(23);
94 sll.push_front(47);
95 // { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }
96
97 std::vector<int> v;
98 v.push_back(1);
99 v.push_back(2);
100 std::vector<int>::iterator viter0;
101 // { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
102 std::vector<int>::iterator viter1 = v.begin();
103 std::vector<int>::iterator viter2 = viter1 + 1;
104 v.erase(viter1);
105 // { dg-final { note-test v {std::__debug::vector of length 1, capacity 2 = {2}} } }
106 // { dg-final { note-test viter1 {invalid iterator} } }
107 // { dg-final { note-test viter2 {invalid iterator} } }
108 std::vector<int>::iterator viter3 = v.begin();
109 // { dg-final { note-test viter3 {2} } }
110
111 __gnu_cxx::slist<int>::iterator slliter = sll.begin();
112 // { dg-final { note-test slliter {47} } }
113
114 std::cout << "\n";
115 return 0; // Mark SPOT
116 }
117
118 // { dg-final { gdb-test SPOT } }