| 1 |
/* Verify __builtin_has_attribute return value for attributes constructor |
| 2 |
and destructor with explicit priorities. |
| 3 |
{ dg-do compile { target init_priority } } |
| 4 |
{ dg-options "-Wall -ftrack-macro-expansion=0" } |
| 5 |
{ dg-options "-Wall -Wno-narrowing -Wno-unused -ftrack-macro-expansion=0" { target c++ } } */ |
| 6 |
|
| 7 |
#define ATTR(...) __attribute__ ((__VA_ARGS__)) |
| 8 |
|
| 9 |
#define A(expect, sym, attr) \ |
| 10 |
typedef int Assert [1 - 2 * !(__builtin_has_attribute (sym, attr) == expect)] |
| 11 |
|
| 12 |
void fnone (void); |
| 13 |
|
| 14 |
void test_ctor_dtor_prio (void) |
| 15 |
{ |
| 16 |
extern ATTR (constructor) void fctor (void); |
| 17 |
extern ATTR (destructor) void fdtor (void); |
| 18 |
extern ATTR (constructor, destructor) void fctor_dtor (void); |
| 19 |
|
| 20 |
A (0, fnone, constructor); |
| 21 |
A (0, fnone, constructor (123)); |
| 22 |
A (0, fnone, destructor); |
| 23 |
A (0, fnone, constructor (234)); |
| 24 |
|
| 25 |
A (1, fctor, constructor); |
| 26 |
A (0, fctor, constructor (123)); |
| 27 |
A (1, fdtor, destructor); |
| 28 |
A (0, fdtor, destructor (234)); |
| 29 |
|
| 30 |
extern ATTR (constructor) void fctor_dtor (void); |
| 31 |
extern ATTR (destructor) void fctor_dtor (void); |
| 32 |
extern ATTR (constructor, destructor) void fctor_dtor (void); |
| 33 |
|
| 34 |
A (1, fctor_dtor, constructor); |
| 35 |
A (1, fctor_dtor, destructor); |
| 36 |
|
| 37 |
extern ATTR (constructor (123)) void fctor_123 (void); |
| 38 |
A (1, fctor_123, constructor); |
| 39 |
A (0, fctor_123, destructor); |
| 40 |
A (1, fctor_123, constructor (123)); |
| 41 |
A (0, fctor_123, constructor (124)); |
| 42 |
|
| 43 |
extern ATTR (destructor (234)) void fctor_123 (void); |
| 44 |
A (1, fctor_123, constructor (123)); |
| 45 |
A (1, fctor_123, destructor); |
| 46 |
A (1, fctor_123, destructor (234)); |
| 47 |
A (0, fctor_123, destructor (235)); |
| 48 |
} |