]>
Commit | Line | Data |
---|---|---|
a945c346 | 1 | // Copyright (C) 2017-2024 Free Software Foundation, Inc. |
d34d36ef JW |
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. | |
8 | ||
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. | |
13 | ||
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/>. | |
17 | ||
18 | // { dg-do compile } | |
75404109 | 19 | // { dg-add-options no_pch } |
d34d36ef JW |
20 | |
21 | // Define macros for some common variables names that we must not use for | |
22 | // naming variables, parameters etc. in the library. | |
9a1bc4b4 JW |
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) | |
d34d36ef JW |
25 | #define A ( |
26 | #define B ( | |
27 | #define C ( | |
28 | #define D ( | |
29 | #define E ( | |
30 | #define F ( | |
31 | #define G ( | |
32 | #define H ( | |
dc79eba7 | 33 | // <complex.h> defines I |
d34d36ef JW |
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 | |
8384956a | 58 | #if __cplusplus <= 201703L |
23f75da9 JW |
59 | // <chrono> defines operator""d in C++20 |
60 | #define d ( | |
61 | // <numbers> defines std::numbers::e in C++20 | |
d34d36ef | 62 | #define e ( |
8384956a | 63 | #endif |
d34d36ef JW |
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 ( | |
23f75da9 JW |
105 | #if __cplusplus <= 201703L |
106 | // <chrono> defines operator""y in C++20 | |
d34d36ef | 107 | #define y ( |
23f75da9 | 108 | #endif |
d34d36ef | 109 | #define z ( |
da0ced6e | 110 | |
dc79eba7 JW |
111 | #define attributes ( |
112 | #define bin_op ( | |
113 | #define clockid ( | |
0163bbaa | 114 | #define func ( |
dc79eba7 JW |
115 | #define max_val ( |
116 | #define min_val ( | |
117 | #define object ( | |
118 | #define ostr ( | |
119 | #define policy ( | |
ea567468 | 120 | #define sz ( |
dc79eba7 JW |
121 | #define tinfo ( |
122 | #define tmp ( | |
b0e6a257 | 123 | #define token ( |
2b667beb | 124 | #define value_t ( |
593cda3e | 125 | |
9e1f9bc5 JW |
126 | #if __cplusplus < 201103L |
127 | #define uses_allocator ( | |
128 | #endif | |
129 | ||
23f75da9 JW |
130 | #if __cplusplus < 201402L |
131 | // <complex> defines operator""il | |
132 | #define il ( | |
133 | #endif | |
134 | ||
593cda3e JW |
135 | #if __cplusplus < 201703L |
136 | // <charconv> defines to_chars_result::ptr and to_chars_result::ec | |
137 | #define ec ( | |
138 | #define ptr ( | |
139 | #endif | |
140 | ||
0ded30b3 | 141 | // These clash with newlib so don't use them. |
75f948f0 | 142 | # define __lockable cannot be used as an identifier |
0ded30b3 JW |
143 | # define __packed cannot be used as an identifier |
144 | # define __unused cannot be used as an identifier | |
145 | # define __used cannot be used as an identifier | |
75f948f0 | 146 | |
007680f9 JW |
147 | #ifndef __APPLE__ |
148 | #define __weak predefined qualifier on darwin | |
149 | #define __strong predefined qualifier on darwin | |
150 | #endif | |
75f948f0 | 151 | |
593cda3e JW |
152 | // Common template parameter names |
153 | #define OutputIterator OutputIterator is not a reserved name | |
154 | #define InputIterator InputIterator is not a reserved name | |
155 | #define ForwardIterator ForwardIterator is not a reserved name | |
156 | #define BidirectionalIterator BidirectionalIterator is not a reserved name | |
157 | #define RandomAccessIterator RandomAccessIterator is not a reserved name | |
158 | #define RandomAccessOutputIterator RandomAccessOutputIterator is not a reserved name | |
57766351 | 159 | #define RAI RAI is not a reserved name |
593cda3e JW |
160 | #define RAIter RAIter is not a reserved name |
161 | #define FwdIter FwdIter is not a reserved name | |
162 | #define OutIter OutIter is not a reserved name | |
163 | #define InIter InIter is not a reserved name | |
164 | ||
165 | #define Alloc Alloc is not a reserved name | |
166 | #define BinaryFunction1 BinaryFunction1 is not a reserved name | |
167 | #define BinaryFunction2 BinaryFunction2 is not a reserved name | |
dc79eba7 | 168 | #define BinaryOperation BinaryOperation is not a reserved name |
593cda3e JW |
169 | #define Char Char is not a reserved name |
170 | #define CharT CharT is not a reserved name | |
171 | #define Cmp Cmp is not a reserved name | |
172 | #define Compare Compare is not a reserved name | |
173 | #define Const_Iterator Const_Iterator is not a reserved name | |
174 | #define Const_Key_Reference Const_Key_Reference is not a reserved name | |
175 | #define Const_Node_Iter Const_Node_Iter is not a reserved name | |
176 | #define Const_Pointer Const_Pointer is not a reserved name | |
177 | #define Const_Reference Const_Reference is not a reserved name | |
178 | #define Data Data is not a reserved name | |
179 | #define DiffType DiffType is not a reserved name | |
180 | #define Eq Eq is not a reserved name | |
181 | #define ExecPolicy ExecPolicy is not a reserved name | |
182 | #define Expected Expected is not a reserved name | |
183 | #define External_Load_Access External_Load_Access is not a reserved name | |
184 | #define External_Size_Access External_Size_Access is not a reserved name | |
185 | #define Fn Fn is not a reserved name | |
186 | #define Function Function is not a reserved name | |
187 | #define Functor Functor is not a reserved name | |
188 | #define Hash Hash is not a reserved name | |
189 | #define H1 H1 is not a reserved name | |
190 | #define H2 H2 is not a reserved name | |
191 | #define Head Head is not a reserved name | |
dc79eba7 | 192 | #define IsVector IsVector is not a reserved name |
593cda3e JW |
193 | #define It It is not a reserved name |
194 | #define Iter Iter is not a reserved name | |
195 | #define Iterator Iterator is not a reserved name | |
196 | #define Key Key is not a reserved name | |
197 | #define Mapped Mapped is not a reserved name | |
198 | #define Node Node is not a reserved name | |
199 | #define Node_iter Node_iter is not a reserved name | |
200 | #define Node_ptr Node_ptr is not a reserved name | |
201 | #define Overflow Overflow is not a reserved name | |
202 | #define Pointer Pointer is not a reserved name | |
203 | #define Policy Policy is not a reserved name | |
204 | #define Pred Pred is not a reserved name | |
dc79eba7 JW |
205 | #define Proj Proj is not a reserved name |
206 | #define Proj1 Proj1 is not a reserved name | |
207 | #define Proj2 Proj2 is not a reserved name | |
593cda3e JW |
208 | #define Ptr Ptr is not a reserved name |
209 | #define Reference Reference is not a reserved name | |
210 | #define Seq Seq is not a reserved name | |
211 | #define Seq_RAIter Seq_RAIter is not a reserved name | |
212 | #define Series Series is not a reserved name | |
213 | #define Set Set is not a reserved name | |
dc79eba7 | 214 | #define Size Size is not a reserved name |
593cda3e JW |
215 | #define String String is not a reserved name |
216 | #define Tp Tp is not a reserved name | |
dc79eba7 | 217 | #define TQual TQual is not a reserved name |
593cda3e JW |
218 | #define Traits Traits is not a reserved name |
219 | #define Type Type is not a reserved name | |
dc79eba7 | 220 | #define UQual UQual is not a reserved name |
593cda3e JW |
221 | #define Value Value is not a reserved name |
222 | #define ValueT ValueT is not a reserved name | |
223 | #define ValueType ValueType is not a reserved name | |
224 | ||
cb363fd9 JW |
225 | #ifndef _WIN32 |
226 | // Windows SAL annotations | |
227 | #define _In_ cannot be used as an identifier | |
228 | #define _Inout_ cannot be used as an identifier | |
229 | #define _Out_ cannot be used as an identifier | |
230 | #define _Reserved_ cannot be used as an identifier | |
231 | #define __inout cannot be used as an identifier | |
232 | #define __in_opt cannot be used as an identifier | |
233 | #define __out_opt cannot be used as an identifier | |
234 | #endif | |
235 | ||
da0ced6e JW |
236 | #ifdef _AIX |
237 | // See https://gcc.gnu.org/ml/libstdc++/2017-03/msg00015.html | |
238 | #undef f | |
239 | #undef r | |
240 | #undef x | |
241 | #undef y | |
1a8d1f54 JW |
242 | // <sys/var.h> defines vario::v |
243 | #undef v | |
64cdf499 JW |
244 | // <sys/timer.h> defines trb::func and cputime_tmr::func |
245 | #undef func | |
25264f6b JW |
246 | // <sys/thread.h> defines tstate::policy |
247 | #undef policy | |
da0ced6e JW |
248 | #endif |
249 | ||
6f4b0ff2 IS |
250 | #ifdef __APPLE__ |
251 | // inttypes.h: extern intmax_t imaxabs(intmax_t j); | |
252 | #undef j | |
253 | #endif | |
254 | ||
ab7fc02e JDA |
255 | #ifdef __hpux__ |
256 | #undef d | |
257 | #undef r | |
258 | #endif | |
259 | ||
e83a5a6b JW |
260 | #if defined (__linux__) && defined (__arm__) |
261 | // <sys/ucontext.h> defines fpregset_t::fpregs::j | |
262 | #undef j | |
263 | #endif | |
264 | ||
d0453cf5 JW |
265 | #if defined (__linux__) && defined (__powerpc__) |
266 | // <asm/types.h> defines __vector128::u | |
267 | #undef u | |
268 | #endif | |
269 | ||
229433c9 EB |
270 | #if defined (__linux__) && defined (__sparc__) |
271 | #undef y | |
272 | #endif | |
273 | ||
815e5740 JJ |
274 | #if defined (__linux__) || defined (__gnu_hurd__) |
275 | #if __has_include(<features.h>) | |
276 | #include <features.h> | |
277 | #if __GLIBC__ == 2 && __GLIBC_MINOR__ < 19 | |
2a23b93f JW |
278 | // Glibc defines this prior to 2.19 |
279 | #undef __unused | |
280 | #endif | |
281 | #endif | |
815e5740 | 282 | #endif |
2a23b93f | 283 | |
75f948f0 | 284 | #if __has_include(<newlib.h>) |
0ded30b3 | 285 | // newlib's <sys/cdefs.h> defines these as macros. |
75f948f0 | 286 | #undef __lockable |
0ded30b3 JW |
287 | #undef __packed |
288 | #undef __unused | |
289 | #undef __used | |
e83a5a6b JW |
290 | // newlib's <time.h> defines __tzrule_type with these members. |
291 | #undef d | |
292 | #undef m | |
293 | #undef n | |
294 | #undef s | |
295 | // newlib's <math.h> uses this for parameters | |
296 | #undef x | |
297 | // newlib's <inttypes.h> uses this for parameters | |
298 | #undef j | |
75404109 JW |
299 | #endif |
300 | ||
7f67becc | 301 | #ifdef __sun__ |
69b09c55 JW |
302 | // <fenv.h> defines these as members of fex_numeric_t |
303 | #undef l | |
304 | #undef f | |
305 | #undef d | |
306 | #undef q | |
307 | #undef p | |
7f67becc JW |
308 | // See https://gcc.gnu.org/ml/libstdc++/2019-05/msg00175.html |
309 | #undef ptr | |
88037d82 RO |
310 | // <sys/timespec_util.h> uses this as parameter |
311 | #undef r | |
312 | // <stdlib.h> uses this as member of drand48_data | |
313 | #undef x | |
7f67becc JW |
314 | #endif |
315 | ||
eb81c997 OH |
316 | #ifdef __VXWORKS__ |
317 | ||
318 | #include <_vxworks-versions.h> | |
319 | ||
320 | // Some VxWorks 6 or 7 headers are using those. | |
321 | ||
322 | // private/objLibP.h | |
323 | #undef u | |
324 | ||
325 | // arch/ppc/ffs/ArchLib.h | |
326 | #undef i | |
327 | #undef j | |
328 | ||
329 | // math.h | |
330 | #undef x | |
331 | #undef y | |
332 | ||
333 | // stdio.h | |
334 | #undef ptr | |
335 | ||
336 | // VxWorks >= 7 specificities | |
337 | ||
338 | #if _VXWORKS_MAJOR_GE(7) | |
339 | ||
340 | // regs.h regs structure has a field 'r' | |
341 | #undef r | |
342 | ||
343 | #ifndef __RTP__ | |
344 | // in bootLib.h, bootParamCheck has parameters x, a-f | |
345 | #undef a | |
346 | #undef b | |
347 | #undef c | |
348 | #undef d | |
349 | #undef e | |
350 | #undef f | |
937692f2 AO |
351 | // in sysLib.h, func appears as a formal parameter name |
352 | #undef func | |
eb81c997 OH |
353 | #endif // __RTP__ |
354 | ||
355 | #endif // VxWorks Major >= 7 | |
356 | ||
357 | #endif // __VXWORKS__ | |
358 | ||
f1a08f4d JW |
359 | #ifdef _WIN32 |
360 | #undef Value | |
361 | // <stdlib.h> defines _CRT_FLOAT::f | |
362 | #undef f | |
363 | // <stdlib.h> defines _CRT_DOUBLE::x and _LONGDOUBLE::x | |
364 | #undef x | |
365 | // <math.h> defines _complex::x and _complex::y | |
366 | #undef y | |
367 | #endif | |
368 | ||
d34d36ef | 369 | #include <bits/stdc++.h> |