xfail dg-final "Sunk statements: 5" on hppa*64*-*-*
[official-gcc.git] / libstdc++-v3 / testsuite / 17_intro / names.cc
blob53c5aff219d317f505167d8238140e1664486e13
1 // Copyright (C) 2017-2024 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do compile }
19 // { dg-add-options no_pch }
21 // Define macros for some common variables names that we must not use for
22 // naming variables, parameters etc. in the library.
23 // N.B. we cannot use '#pragma GCC poison A' because that also prevents using
24 // these names even as macro arguments, e.g. #define FOO(A) BAR(A)
25 #define A (
26 #define B (
27 #define C (
28 #define D (
29 #define E (
30 #define F (
31 #define G (
32 #define H (
33 // <complex.h> defines I
34 #define J (
35 #define K (
36 #define L (
37 #define M (
38 #define N (
39 #define O (
40 #define P (
41 #define Q (
42 #define R (
43 #define S (
44 #define T (
45 #define U (
46 #define V (
47 #define W (
48 #define X (
49 #define Y (
50 #define Z (
51 #if __cplusplus >= 201103L
52 // <random> defines member functions called a() and b()
53 #else
54 #define a (
55 #define b (
56 #endif
57 // <queue> and <stack> defined data members called c
58 #if __cplusplus <= 201703L
59 // <chrono> defines operator""d in C++20
60 #define d (
61 // <numbers> defines std::numbers::e in C++20
62 #define e (
63 #endif
64 #define f (
65 #define g (
66 #if __cplusplus >= 201402L
67 // <chrono> defines operator ""h in C++14
68 // <complex> defines operator ""i in C++14
69 #else
70 #define h (
71 #define i (
72 #endif
73 #define j (
74 #if __cplusplus >= 201103L
75 // <random> defines member functions called k()
76 #else
77 #define k (
78 #endif
79 #define l (
80 #if __cplusplus >= 201103L
81 // <random> defines member functions called m() and n()
82 #else
83 #define m (
84 #define n (
85 #endif
86 #define o (
87 #if __cplusplus >= 201103L
88 // <random> defines member functions called p()
89 #else
90 #define p (
91 #endif
92 #define q (
93 #define r (
94 #if __cplusplus >= 201103L
95 // <random> defines member functions called s() and t()
96 // <chrono> and <string> define operator ""s in C++14
97 #else
98 #define s (
99 #define t (
100 #endif
101 #define u (
102 #define v (
103 #define w (
104 #define x (
105 #if __cplusplus <= 201703L
106 // <chrono> defines operator""y in C++20
107 #define y (
108 #endif
109 #define z (
111 #define attributes (
112 #define bin_op (
113 #define clockid (
114 #define func (
115 #define max_val (
116 #define min_val (
117 #define object (
118 #define ostr (
119 #define policy (
120 #define sz (
121 #define tinfo (
122 #define tmp (
123 #define token (
124 #define value_t (
126 #if __cplusplus < 201103L
127 #define uses_allocator (
128 #endif
130 #if __cplusplus < 201402L
131 // <complex> defines operator""il
132 #define il (
133 #endif
135 #if __cplusplus < 201703L
136 // <charconv> defines to_chars_result::ptr and to_chars_result::ec
137 #define ec (
138 #define ptr (
139 #endif
141 // These clash with newlib so don't use them.
142 # define __lockable cannot be used as an identifier
143 # define __null_sentinel cannot be used as an identifier
144 # define __packed cannot be used as an identifier
145 # define __unused cannot be used as an identifier
146 # define __used cannot be used as an identifier
148 #ifndef __APPLE__
149 #define __weak predefined qualifier on darwin
150 #define __strong predefined qualifier on darwin
151 #endif
153 // Common template parameter names
154 #define OutputIterator OutputIterator is not a reserved name
155 #define InputIterator InputIterator is not a reserved name
156 #define ForwardIterator ForwardIterator is not a reserved name
157 #define BidirectionalIterator BidirectionalIterator is not a reserved name
158 #define RandomAccessIterator RandomAccessIterator is not a reserved name
159 #define RandomAccessOutputIterator RandomAccessOutputIterator is not a reserved name
160 #define RAI RAI is not a reserved name
161 #define RAIter RAIter is not a reserved name
162 #define FwdIter FwdIter is not a reserved name
163 #define OutIter OutIter is not a reserved name
164 #define InIter InIter is not a reserved name
166 #define Alloc Alloc is not a reserved name
167 #define BinaryFunction1 BinaryFunction1 is not a reserved name
168 #define BinaryFunction2 BinaryFunction2 is not a reserved name
169 #define BinaryOperation BinaryOperation is not a reserved name
170 #define Char Char is not a reserved name
171 #define CharT CharT is not a reserved name
172 #define Cmp Cmp is not a reserved name
173 #define Compare Compare is not a reserved name
174 #define Const_Iterator Const_Iterator is not a reserved name
175 #define Const_Key_Reference Const_Key_Reference is not a reserved name
176 #define Const_Node_Iter Const_Node_Iter is not a reserved name
177 #define Const_Pointer Const_Pointer is not a reserved name
178 #define Const_Reference Const_Reference is not a reserved name
179 #define Data Data is not a reserved name
180 #define DiffType DiffType is not a reserved name
181 #define Eq Eq is not a reserved name
182 #define ExecPolicy ExecPolicy is not a reserved name
183 #define Expected Expected is not a reserved name
184 #define External_Load_Access External_Load_Access is not a reserved name
185 #define External_Size_Access External_Size_Access is not a reserved name
186 #define Fn Fn is not a reserved name
187 #define Function Function is not a reserved name
188 #define Functor Functor is not a reserved name
189 #define Hash Hash is not a reserved name
190 #define H1 H1 is not a reserved name
191 #define H2 H2 is not a reserved name
192 #define Head Head is not a reserved name
193 #define IsVector IsVector is not a reserved name
194 #define It It is not a reserved name
195 #define Iter Iter is not a reserved name
196 #define Iterator Iterator is not a reserved name
197 #define Key Key is not a reserved name
198 #define Mapped Mapped is not a reserved name
199 #define Node Node is not a reserved name
200 #define Node_iter Node_iter is not a reserved name
201 #define Node_ptr Node_ptr is not a reserved name
202 #define Overflow Overflow is not a reserved name
203 #define Pointer Pointer is not a reserved name
204 #define Policy Policy is not a reserved name
205 #define Pred Pred is not a reserved name
206 #define Proj Proj is not a reserved name
207 #define Proj1 Proj1 is not a reserved name
208 #define Proj2 Proj2 is not a reserved name
209 #define Ptr Ptr is not a reserved name
210 #define Reference Reference is not a reserved name
211 #define Seq Seq is not a reserved name
212 #define Seq_RAIter Seq_RAIter is not a reserved name
213 #define Series Series is not a reserved name
214 #define Set Set is not a reserved name
215 #define Size Size is not a reserved name
216 #define String String is not a reserved name
217 #define Tp Tp is not a reserved name
218 #define TQual TQual is not a reserved name
219 #define Traits Traits is not a reserved name
220 #define Type Type is not a reserved name
221 #define UQual UQual is not a reserved name
222 #define Value Value is not a reserved name
223 #define ValueT ValueT is not a reserved name
224 #define ValueType ValueType is not a reserved name
226 #ifndef _WIN32
227 // Windows SAL annotations
228 #define _In_ cannot be used as an identifier
229 #define _Inout_ cannot be used as an identifier
230 #define _Out_ cannot be used as an identifier
231 #define _Reserved_ cannot be used as an identifier
232 #define __inout cannot be used as an identifier
233 #define __in_opt cannot be used as an identifier
234 #define __out_opt cannot be used as an identifier
235 #endif
237 #ifdef _AIX
238 // See https://gcc.gnu.org/ml/libstdc++/2017-03/msg00015.html
239 #undef f
240 #undef r
241 #undef x
242 #undef y
243 // <sys/var.h> defines vario::v
244 #undef v
245 // <sys/timer.h> defines trb::func and cputime_tmr::func
246 #undef func
247 // <sys/thread.h> defines tstate::policy
248 #undef policy
249 #endif
251 #ifdef __APPLE__
252 // inttypes.h: extern intmax_t imaxabs(intmax_t j);
253 #undef j
254 #endif
256 #ifdef __hpux__
257 #undef d
258 #undef r
259 #endif
261 #if defined (__linux__) && defined (__arm__)
262 // <sys/ucontext.h> defines fpregset_t::fpregs::j
263 #undef j
264 #endif
266 #if defined (__linux__) && defined (__powerpc__)
267 // <asm/types.h> defines __vector128::u
268 #undef u
269 #endif
271 #if defined (__linux__) && defined (__sparc__)
272 #undef y
273 #endif
275 #if defined (__linux__) || defined (__gnu_hurd__)
276 #if __has_include(<features.h>)
277 #include <features.h>
278 #if __GLIBC__ == 2 && __GLIBC_MINOR__ < 19
279 // Glibc defines this prior to 2.19
280 #undef __unused
281 #endif
282 #endif
283 #endif
285 #if __has_include(<newlib.h>)
286 // newlib's <sys/cdefs.h> defines these as macros.
287 #undef __lockable
288 #undef __packed
289 #undef __unused
290 #undef __used
291 // newlib's <time.h> defines __tzrule_type with these members.
292 #undef d
293 #undef m
294 #undef n
295 #undef s
296 // newlib's <math.h> uses this for parameters
297 #undef x
298 // newlib's <inttypes.h> uses this for parameters
299 #undef j
300 #endif
302 #ifdef __sun__
303 // <fenv.h> defines these as members of fex_numeric_t
304 #undef l
305 #undef f
306 #undef d
307 #undef q
308 #undef p
309 // See https://gcc.gnu.org/ml/libstdc++/2019-05/msg00175.html
310 #undef ptr
311 // <sys/timespec_util.h> uses this as parameter
312 #undef r
313 // <stdlib.h> uses this as member of drand48_data
314 #undef x
315 #endif
317 #ifdef __VXWORKS__
319 #include <_vxworks-versions.h>
321 // Some VxWorks 6 or 7 headers are using those.
323 // private/objLibP.h
324 #undef u
326 // arch/ppc/ffs/ArchLib.h
327 #undef i
328 #undef j
330 // math.h
331 #undef x
332 #undef y
334 // stdio.h
335 #undef ptr
337 // VxWorks >= 7 specificities
339 #if _VXWORKS_MAJOR_GE(7)
341 // regs.h regs structure has a field 'r'
342 #undef r
344 #ifndef __RTP__
345 // in bootLib.h, bootParamCheck has parameters x, a-f
346 #undef a
347 #undef b
348 #undef c
349 #undef d
350 #undef e
351 #undef f
352 // in sysLib.h, func appears as a formal parameter name
353 #undef func
354 #endif // __RTP__
356 #endif // VxWorks Major >= 7
358 #endif // __VXWORKS__
360 #ifdef _WIN32
361 #undef Value
362 // <stdlib.h> defines _CRT_FLOAT::f
363 #undef f
364 // <stdlib.h> defines _CRT_DOUBLE::x and _LONGDOUBLE::x
365 #undef x
366 // <math.h> defines _complex::x and _complex::y
367 #undef y
368 #endif
370 #include <bits/stdc++.h>