c++: unresolved overload with comma op [PR115430]
[official-gcc.git] / gcc / testsuite / gcc.dg / Wattributes-6.c
blob49a085def9ecdb3ec33b4739ecba0542a2289dac
1 /* { dg-do compile }
2 { dg-options "-Wall -Wattributes -ftrack-macro-expansion=0" } */
4 #define ATTR(attrlist) __attribute__ (attrlist)
6 /* Exercise the handling of the mutually exclusive attributes
7 aligned and packed on a type definition. */
9 /* Pointless but benign. */
10 struct ATTR ((aligned, aligned))
11 AlignedAligned { int i; };
13 /* Aligned followed by packed on a type and vice versa has a valid use:
14 to decrease the alignment of a type to the specified boundary. */
15 struct ATTR ((aligned, packed))
16 AlignedPacked { int i; };
18 struct ATTR ((packed, aligned))
19 PackedAligned { int i; };
21 struct ATTR ((aligned (2)))
22 AlignedMemberPacked
24 int ATTR ((packed)) i; // { dg-warning "attribute ignored" "" { target default_packed } }
27 struct ATTR ((packed))
28 PackedMemberAligned
30 int ATTR ((aligned (2))) i;
33 /* Silly but benign. */
34 struct ATTR ((packed, packed))
35 PackedPacked { int i; };
38 /* Exercise the handling of the mutually exclusive attributes
39 aligned and packed on a function declaration. */
41 void ATTR ((aligned (8), packed))
42 faligned8_1 (void); /* { dg-warning "ignoring attribute .packed. because it conflicts with attribute .aligned." } */
44 void ATTR ((aligned (8)))
45 faligned8_2 (void); /* { dg-message "previous declaration here" } */
47 void ATTR ((packed))
48 faligned8_2 (void); /* { dg-warning "ignoring attribute .packed. because it conflicts with attribute .aligned." } */
50 /* Exercise the handling of the mutually exclusive attributes
51 always_inline and noinline (in that order). */
53 inline void ATTR ((always_inline))
54 falways_inline1 (void);
56 inline void ATTR ((__always_inline__))
57 falways_inline1 (void);
59 /* Verify that repeating attribute always_inline on the same declaration
60 doesn't trigger a warning. */
61 inline void ATTR ((always_inline, __always_inline__))
62 falways_inline1 (void);
64 /* Verify that repeating attribute always_inline on a distinct declaration
65 doesn't trigger a warning. */
66 inline void ATTR ((always_inline))
67 falways_inline1 (void); /* { dg-message "previous declaration here" } */
69 /* Verify a warning for noinline conflict. */
70 void ATTR ((noinline))
71 falways_inline1 (void) { } /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */
73 /* And again. */
74 void ATTR ((always_inline))
75 falways_inline1 (void);
78 /* Exercise the handling of the mutually exclusive attributes
79 noinline and always_inline (in that order). */
81 void ATTR ((noinline))
82 fnoinline1 (void);
84 void ATTR ((__noinline__))
85 fnoinline1 (void);
87 /* Verify that repeating attribute noinline on the same declaration
88 doesn't trigger a warning. */
89 void ATTR ((noinline, __noinline__))
90 fnoinline1 (void);
92 /* Verify that repeating attribute noinline on a distinct declaration
93 doesn't trigger a warning. */
94 void ATTR ((noinline))
95 fnoinline1 (void); /* { dg-message "previous declaration here" } */
97 /* Verify a warning for always_inline conflict. */
98 void ATTR ((always_inline))
99 fnoinline1 (void) { } /* { dg-warning "ignoring attribute .always_inline. because it conflicts with attribute .noinline." } */
100 /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
101 /* { dg-note "previous definition" "" { target *-*-* } .-2 } */
103 /* Verify a warning for gnu_inline conflict. */
104 inline void ATTR ((gnu_inline))
105 fnoinline1 (void); /* { dg-warning "ignoring attribute .gnu_inline. because it conflicts with attribute .noinline." } */
106 /* { dg-warning "follows declaration with attribute .noinline." "inline noinline" { target *-*-* } .-1 } */
108 /* And again. */
109 void ATTR ((noinline))
110 fnoinline1 (void); /* { dg-warning "follows inline declaration" } */
113 /* Exercise the handling of the mutually exclusive attributes
114 noreturn and warn_unused_result. */
116 int ATTR ((__noreturn__))
117 fnoret1 (void);
119 int ATTR ((noreturn))
120 fnoret1 (void); /* { dg-message "previous declaration here" } */
122 int ATTR ((warn_unused_result))
123 fnoret1 (void); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */
125 /* Verify that repeating attribute noreturn doesn't trigger a warning. */
126 int ATTR ((noreturn)) fnoret1 (void);
128 int call_noret1 (void)
130 /* Verify that attribute warn_unused_result was, in fact, ignored
131 on the second declaration of fnoret1. */
132 fnoret1 ();
135 int ATTR ((noreturn, warn_unused_result))
136 fnoret2 (void); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */
138 /* Verify that repeating attribute noreturn doesn't trigger a warning. */
139 int ATTR ((noreturn)) fnoret2 (void);
141 int call_noret2 (void)
143 /* Verify that attribute warn_unused_result was, in fact, ignored
144 on the second declaration of fnoret2. */
145 fnoret2 ();
148 /* Verify that attribute noreturn isn't diagnosed on a declaration
149 that was previously declared warn_unused_result and that attribute
150 was dropped (because the function returs void). */
152 void ATTR ((warn_unused_result))
153 fnorety6 (void); /* { dg-warning ".warn_unused_result. attribute ignored" } */
155 void ATTR ((noreturn))
156 fnoret6 (void);
159 /* Exercise the handling of the mutually exclusive attributes
160 noreturn and alloc_align. */
162 void* ATTR ((noreturn))
163 fnoret_alloc_align1 (int); /* { dg-message "previous declaration here" } */
165 void* ATTR ((alloc_align (1)))
166 fnoret_alloc_align1 (int); /* { dg-warning "ignoring attribute .alloc_align. because it conflicts with attribute .noreturn." } */
168 void* ATTR ((noreturn, alloc_align (1)))
169 fnoret_alloc_align2 (int); /* { dg-warning "ignoring attribute .alloc_align. because it conflicts with attribute .noreturn." } */
172 void* ATTR ((noreturn)) ATTR ((alloc_align (1)))
173 fnoret_alloc_align3 (int); /* { dg-warning "ignoring attribute .alloc_align. because it conflicts with attribute .noreturn." } */
176 void* ATTR ((alloc_align (1)))
177 falloc_align_noret1 (int); /* { dg-message "previous declaration here" } */
179 void* ATTR ((noreturn))
180 falloc_align_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_align." } */
183 void* ATTR ((alloc_align (1), noreturn))
184 falloc_align_noret2 (int); /* { dg-warning "ignoring attribute .(noreturn|alloc_align). because it conflicts with attribute .(alloc_align|noreturn)." } */
186 void* ATTR ((alloc_align (1))) ATTR ((noreturn))
187 falloc_align_noret3 (int); /* { dg-warning "ignoring attribute .(noreturn|alloc_align). because it conflicts with attribute .(noreturn|alloc_align)." } */
190 /* Exercise the handling of the mutually exclusive attributes
191 noreturn and alloc_size. */
193 void* ATTR ((noreturn))
194 fnoret_alloc_size1 (int); /* { dg-message "previous declaration here" } */
196 void* ATTR ((alloc_size (1)))
197 fnoret_alloc_size1 (int); /* { dg-warning "ignoring attribute .alloc_size. because it conflicts with attribute .noreturn." } */
199 void* ATTR ((noreturn, alloc_size (1)))
200 fnoret_alloc_size2 (int); /* { dg-warning "ignoring attribute .alloc_size. because it conflicts with attribute .noreturn." } */
203 void* ATTR ((noreturn)) ATTR ((alloc_size (1)))
204 fnoret_alloc_size3 (int); /* { dg-warning "ignoring attribute .alloc_size. because it conflicts with attribute .noreturn." } */
207 void* ATTR ((alloc_size (1)))
208 falloc_size_noret1 (int); /* { dg-message "previous declaration here" } */
210 void* ATTR ((noreturn))
211 falloc_size_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_size." } */
214 void* ATTR ((alloc_size (1), noreturn))
215 falloc_size_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_size." } */
217 void* ATTR ((alloc_size (1))) ATTR ((noreturn))
218 falloc_size_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_size." } */
221 /* Exercise the handling of the mutually exclusive attributes
222 noreturn and const. */
224 int ATTR ((noreturn))
225 fnoret_const1 (int); /* { dg-message "previous declaration here" } */
227 int ATTR ((const))
228 fnoret_const1 (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */
230 /* Unfortunately, attributes on a single declarations may not be processed
231 in the same order as specified... */
232 int ATTR ((noreturn, const))
233 fnoret_const2 (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */
236 int ATTR ((noreturn)) ATTR ((const))
237 fnoret_const3 (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */
240 int ATTR ((const))
241 fconst_noret1 (int); /* { dg-message "previous declaration here" } */
243 int ATTR ((noreturn))
244 fconst_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .const." } */
247 int ATTR ((const, noreturn))
248 fconst_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .const." } */
250 int ATTR ((const)) ATTR ((noreturn))
251 fconst_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .const." } */
254 /* Exercise the handling of the mutually exclusive attributes
255 noreturn and malloc. */
257 void* ATTR ((noreturn))
258 fnoret_malloc1 (int); /* { dg-message "previous declaration here" } */
260 void* ATTR ((malloc))
261 fnoret_malloc1 (int); /* { dg-warning "ignoring attribute .malloc. because it conflicts with attribute .noreturn." } */
263 /* Unfortunately, attributes on a single declarations may not be processed
264 in the same order as specified... */
265 void* ATTR ((noreturn, malloc))
266 fnoret_malloc2 (int); /* { dg-warning "ignoring attribute .malloc. because it conflicts with attribute .noreturn." } */
269 void* ATTR ((noreturn)) ATTR ((malloc))
270 fnoret_malloc3 (int); /* { dg-warning "ignoring attribute .malloc. because it conflicts with attribute .noreturn." } */
273 void* ATTR ((__malloc__))
274 fmalloc_noret1 (int);
276 void* ATTR ((malloc))
277 fmalloc_noret1 (int); /* { dg-message "previous declaration here" } */
279 void* ATTR ((noreturn))
280 fmalloc_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .malloc." } */
283 void* ATTR ((malloc, noreturn))
284 fmalloc_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .malloc." } */
286 void* ATTR ((malloc)) ATTR ((noreturn))
287 fmalloc_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .malloc." } */
290 /* Exercise the handling of the mutually exclusive attributes
291 noreturn and pure. */
293 int ATTR ((noreturn))
294 fnoret_pure1 (int); /* { dg-message "previous declaration here" } */
296 int ATTR ((pure))
297 fnoret_pure1 (int); /* { dg-warning "ignoring attribute .pure. because it conflicts with attribute .noreturn." } */
299 /* Unfortunately, attributes on a single declarations may not be processed
300 in the same order as specified... */
301 int ATTR ((noreturn, pure))
302 fnoret_pure2 (int); /* { dg-warning "ignoring attribute .pure. because it conflicts with attribute .noreturn." } */
305 int ATTR ((noreturn)) ATTR ((pure))
306 fnoret_pure3 (int); /* { dg-warning "ignoring attribute .pure. because it conflicts with attribute .noreturn." } */
309 int ATTR ((__pure__))
310 fpure_noret1 (int);
312 int ATTR ((pure))
313 fpure_noret1 (int); /* { dg-message "previous declaration here" } */
315 int ATTR ((noreturn))
316 fpure_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .pure." } */
319 int ATTR ((pure, noreturn))
320 fpure_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .pur." } */
322 int ATTR ((pure)) ATTR ((noreturn))
323 fpure_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .pure." } */
326 /* Exercise the handling of the mutually exclusive attributes
327 noreturn and returns_twice. */
329 int ATTR ((noreturn))
330 fnoret_returns_twice1 (int); /* { dg-message "previous declaration here" } */
332 int ATTR ((returns_twice))
333 fnoret_returns_twice1 (int); /* { dg-warning "ignoring attribute .returns_twice. because it conflicts with attribute .noreturn." } */
335 /* Unfortunately, attributes on a single declarations may not be processed
336 in the same order as specified... */
337 int ATTR ((noreturn, returns_twice))
338 fnoret_returns_twice2 (int); /* { dg-warning "ignoring attribute .returns_twice. because it conflicts with attribute .noreturn." } */
341 int ATTR ((noreturn)) ATTR ((returns_twice))
342 fnoret_returns_twice3 (int); /* { dg-warning "ignoring attribute .returns_twice. because it conflicts with attribute .noreturn." } */
345 int ATTR ((returns_twice))
346 freturns_twice_noret1 (int); /* { dg-message "previous declaration here" } */
348 int ATTR ((noreturn))
349 freturns_twice_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .returns_twice." } */
352 int ATTR ((returns_twice, noreturn))
353 freturns_twice_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .returns_twice." } */
355 int ATTR ((returns_twice)) ATTR ((noreturn))
356 freturns_twice_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .returns_twice." } */
359 /* Exercise the interaction of multiple combinations of mutually
360 exclusive attributes specified on distinct declarations. */
362 inline int ATTR ((always_inline))
363 finline_cold_noreturn (int);
365 inline int ATTR ((cold))
366 finline_cold_noreturn (int);
368 inline int ATTR ((noreturn))
369 finline_cold_noreturn (int); /* { dg-note "previous declaration here" } */
371 inline int ATTR ((noinline))
372 finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */
373 /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
375 inline int ATTR ((hot))
376 finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .hot. because it conflicts with attribute .cold." } */
377 /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
379 inline int ATTR ((warn_unused_result))
380 finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */
382 inline int ATTR ((always_inline))
383 finline_cold_noreturn (int);
385 /* Expect no warning for the missing return statement below because
386 the function is noreturn. */
387 inline int ATTR ((noreturn))
388 finline_cold_noreturn (int i) { (void)&i; __builtin_abort (); }
391 /* Exercise the interaction of multiple combinations of mutually
392 exclusive attributes with some specified on the same declaration
393 and some on distinct declarations. */
395 inline int ATTR ((always_inline, hot))
396 finline_hot_noret_align (int); /* { dg-note "previous declaration here" } */
398 inline int ATTR ((noreturn, noinline))
399 finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */
400 /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
402 inline int ATTR ((cold, aligned (8)))
403 finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .cold. because it conflicts with attribute .hot." } */
404 /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
406 inline int ATTR ((warn_unused_result))
407 finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */
408 /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
410 inline int ATTR ((aligned (4)))
411 finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(8\\)." "" } */
413 inline int ATTR ((aligned (8)))
414 finline_hot_noret_align (int); /* { dg-note "previous declaration here" } */
416 inline int ATTR ((const))
417 finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */
419 /* Expect no warning for the missing return statement below because
420 the function is noreturn. */
421 inline int ATTR ((noreturn))
422 finline_hot_noret_align (int i) { (void)&i; __builtin_abort (); }
425 /* Expect a warning about conflicting alignment but without
426 other declarations inbetween. */
427 inline int ATTR ((aligned (32)))
428 finline_align (int); /* { dg-note "previous declaration here" } */
430 inline int ATTR ((aligned (4)))
431 finline_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(32\\)." "" } */
433 inline int ATTR ((noreturn))
434 finline_align (int i) { (void)&i; __builtin_abort (); }
437 /* Expect no note that would refer to the same declaration. */
438 inline int ATTR ((aligned (32), aligned (4)))
439 finline_double_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(32\\)." } */
441 inline int ATTR ((noreturn))
442 finline_double_align (int i) { (void)&i; __builtin_abort (); }
445 /* Exercise variable attributes. */
447 extern int ATTR ((common))
448 decl_common1; /* { dg-message "previous declaration here" } */
450 extern int ATTR ((nocommon))
451 decl_common1; /* { dg-warning "ignoring attribute .nocommon. because it conflicts with attribute .common." } */
454 extern int ATTR ((nocommon))
455 decl_common2; /* { dg-message "previous declaration here" } */
457 extern int ATTR ((common))
458 decl_common2; /* { dg-warning "ignoring attribute .common. because it conflicts with attribute .nocommon." } */
461 extern int ATTR ((common, nocommon))
462 decl_common3; /* { dg-warning "ignoring attribute .nocommon. because it conflicts with attribute .common." } */
465 extern int ATTR ((common, nocommon))
466 decl_common4; /* { dg-warning "ignoring attribute .nocommon. because it conflicts with attribute .common." } */