]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
1 // { dg-do run { target c++11 } }
2 // { dg-options "-g -O0" }
4 // Copyright (C) 2011-2023 Free Software Foundation, Inc.
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)
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.
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/>.
21 #include <forward_list>
22 #include <unordered_map>
23 #include <unordered_set>
28 #include <initializer_list>
30 #include "../util/testsuite_allocator.h" // NullablePointer
32 typedef std::tuple
<int, int> ExTuple
;
36 placeholder(const T
&s
)
41 template<class T
, class S
>
43 placeholder(const std::pair
<T
,S
> &s
)
50 use(const T
&container
)
52 for (typename
T::const_iterator i
= container
.begin();
64 std::unique_ptr
<datum
> global
;
69 std::forward_list
<int> efl
;
70 // { dg-final { regexp-test efl "empty std::(__debug::)?forward_list" } }
72 std::forward_list
<int> &refl
= efl
;
73 // { dg-final { regexp-test refl "empty std::(__debug::)?forward_list" } }
75 std::forward_list
<int> fl
;
78 // { dg-final { regexp-test fl {std::(__debug::)?forward_list = {\[0\] = 1, \[1\] = 2}} } }
80 std::forward_list
<int> &rfl
= fl
;
81 // { dg-final { regexp-test rfl {std::(__debug::)?forward_list = {\[0\] = 1, \[1\] = 2}} } }
83 std::unordered_map
<int, std::string
> eum
;
84 // { dg-final { regexp-test eum "std::(__debug::)?unordered_map with 0 elements" } }
85 std::unordered_map
<int, std::string
> &reum
= eum
;
86 // { dg-final { regexp-test reum "std::(__debug::)?unordered_map with 0 elements" } }
88 std::unordered_multimap
<int, std::string
> eumm
;
89 // { dg-final { regexp-test eumm "std::(__debug::)?unordered_multimap with 0 elements" } }
90 std::unordered_multimap
<int, std::string
> &reumm
= eumm
;
91 // { dg-final { regexp-test reumm "std::(__debug::)?unordered_multimap with 0 elements" } }
93 std::unordered_set
<int> eus
;
94 // { dg-final { regexp-test eus "std::(__debug::)?unordered_set with 0 elements" } }
95 std::unordered_set
<int> &reus
= eus
;
96 // { dg-final { regexp-test reus "std::(__debug::)?unordered_set with 0 elements" } }
98 std::unordered_multiset
<int> eums
;
99 // { dg-final { regexp-test eums "std::(__debug::)?unordered_multiset with 0 elements" } }
100 std::unordered_multiset
<int> &reums
= eums
;
101 // { dg-final { regexp-test reums "std::(__debug::)?unordered_multiset with 0 elements" } }
103 std::unordered_map
<int, std::string
> uom
;
106 // { dg-final { regexp-test uom {std::(__debug::)?unordered_map with 2 elements = {\[3\] = "seven", \[5\] = "three"}} } }
108 std::unordered_map
<int, std::string
> &ruom
= uom
;
109 // { dg-final { regexp-test ruom {std::(__debug::)?unordered_map with 2 elements = {\[3\] = "seven", \[5\] = "three"}} } }
111 std::unordered_multimap
<int, std::string
> uomm
;
112 uomm
.insert(std::pair
<int, std::string
> (5, "three"));
113 uomm
.insert(std::pair
<int, std::string
> (5, "seven"));
114 // { dg-final { regexp-test uomm {std::(__debug::)?unordered_multimap with 2 elements = {\[5\] = "seven", \[5\] = "three"}} } }
115 std::unordered_multimap
<int, std::string
> &ruomm
= uomm
;
116 // { dg-final { regexp-test ruomm {std::(__debug::)?unordered_multimap with 2 elements = {\[5\] = "seven", \[5\] = "three"}} } }
118 std::unordered_set
<int> uos
;
120 // { dg-final { regexp-test uos {std::(__debug::)?unordered_set with 1 element = {\[0\] = 5}} } }
121 std::unordered_set
<int> &ruos
= uos
;
122 // { dg-final { regexp-test ruos {std::(__debug::)?unordered_set with 1 element = {\[0\] = 5}} } }
124 std::unordered_multiset
<int> uoms
;
126 // { dg-final { regexp-test uoms {std::(__debug::)?unordered_multiset with 1 element = {\[0\] = 5}} } }
127 std::unordered_multiset
<int> &ruoms
= uoms
;
128 // { dg-final { regexp-test ruoms {std::(__debug::)?unordered_multiset with 1 element = {\[0\] = 5}} } }
130 std::unique_ptr
<datum
> uptr (new datum
);
133 // { dg-final { regexp-test uptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } }
134 std::unique_ptr
<datum
> &ruptr
= uptr
;
135 // { dg-final { regexp-test ruptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } }
137 using data
= datum
[];
138 std::unique_ptr
<data
> arrptr (new datum
[2]);
139 // { dg-final { regexp-test arrptr {std::unique_ptr.datum \[\]. = {get\(\) = 0x.*}} } }
140 std::unique_ptr
<data
>& rarrptr
= arrptr
;
141 // { dg-final { regexp-test rarrptr {std::unique_ptr.datum \[\]. = {get\(\) = 0x.*}} } }
145 int deleter_member
= -1;
146 using pointer
= __gnu_test::NullablePointer
<void>;
147 void operator()(pointer
) const noexcept
{ }
149 static_assert( !std::is_empty
<Deleter
>(), "Deleter is not empty" );
150 static_assert( std::is_empty
<Deleter::pointer
>(), "but pointer is empty" );
152 std::unique_ptr
<int, Deleter
> empty_ptr
;
153 // { dg-final { note-test empty_ptr {std::unique_ptr<int> = {get() = {<No data fields>}}} } }
154 std::unique_ptr
<int, Deleter
>& rempty_ptr
= empty_ptr
;
155 // { dg-final { note-test rempty_ptr {std::unique_ptr<int> = {get() = {<No data fields>}}} } }
157 struct Deleter_pr103086
159 int deleter_member
= -1;
160 void operator()(int*) const noexcept
{ }
163 std::unique_ptr
<int, Deleter_pr103086
> uniq_ptr
;
164 // { dg-final { note-test uniq_ptr {std::unique_ptr<int> = {get() = 0x0}} } }
165 std::unique_ptr
<int, Deleter_pr103086
>& runiq_ptr
= uniq_ptr
;
166 // { dg-final { note-test runiq_ptr {std::unique_ptr<int> = {get() = 0x0}} } }
169 // { dg-final { note-test tpl {std::tuple containing = {[0] = 6, [1] = 7}} } }
171 // { dg-final { note-test rtpl {std::tuple containing = {[0] = 6, [1] = 7}} } }
174 // { dg-final { note-test e0 {std::error_code = { }} } }
175 std::error_condition ec0
;
176 // { dg-final { note-test ec0 {std::error_condition = { }} } }
177 std::error_code einval
= std::make_error_code(std::errc::invalid_argument
);
178 // { dg-final { note-test einval {std::error_code = {"generic": EINVAL}} } }
179 std::error_condition ecinval
= std::make_error_condition(std::errc::invalid_argument
);
180 // { dg-final { note-test ecinval {std::error_condition = {"generic": EINVAL}} } }
182 struct custom_cat
: std::error_category
{
183 const char* name() const noexcept
{ return "miaow"; }
184 std::string
message(int) const { return ""; }
186 std::error_code
emiaow(42, cat
);
187 // { dg-final { note-test emiaow {std::error_code = {custom_cat: 42}} } }
188 std::error_condition
ecmiaow(42, cat
);
189 // { dg-final { note-test ecmiaow {std::error_condition = {custom_cat: 42}} } }
191 std::error_code ecio
= std::make_error_code(std::io_errc::stream
);
192 // { dg-final { note-test ecio {std::error_code = {"io": stream}} } }
193 std::error_code ecfut0
= std::make_error_code(std::future_errc
{});
194 // { dg-final { note-test ecfut0 {std::error_code = {"future": 0}} } }
196 std::initializer_list
<int> emptyIl
= {};
197 // { dg-final { note-test emptyIl {std::initializer_list of length 0} } }
198 std::initializer_list
<int> il
= {3, 4};
199 // { dg-final { note-test il {std::initializer_list of length 2 = {3, 4}} } }
201 std::atomic
<int> ai
{100};
202 // { dg-final { note-test ai {std::atomic<int> = { 100 }} } }
204 std::atomic
<long*> ap
{&l
};
205 // { dg-final { regexp-test ap {std::atomic.long \*. = { 0x.* }} } }
206 struct Value
{ int i
, j
; };
207 std::atomic
<Value
> av
{{8, 9}};
208 // { dg-final { note-test av {std::atomic<Value> = { {i = 8, j = 9} }} } }
210 placeholder(""); // Mark SPOT
225 // { dg-final { gdb-test SPOT } }