Debian Codegraph @

gcc/testsuite/c-c++-common/initpri2.c

raw
1 /* { dg-do compile { target init_priority } } */
2 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient. */
3
4 /* Priorities must be in the range [0, 65535]. */
5 void c1()
6 __attribute__((constructor (-1))); /* { dg-error "priorities" } */
7 void c2()
8 __attribute__((constructor (65536))); /* { dg-error "priorities" } */
9 void d1()
10 __attribute__((destructor (-1))); /* { dg-error "priorities" } */
11 void d2()
12 __attribute__((destructor (65536))); /* { dg-error "priorities" } */
13
14 /* Priorities 0-100 are reserved for system libraries. */
15 void c3()
16 __attribute__((constructor (50))); /* { dg-warning "reserved" } */
17 void d3()
18 __attribute__((constructor (50))); /* { dg-warning "reserved" } */
19
20 /* Priorities must be integral constants. */
21
22 /* Pointers, even with constant values, are not allowed. */
23 void c4()
24 __attribute__((constructor ((void*) 500))); /* { dg-error "priorities" } */
25 void d4()
26 __attribute__((destructor ((void*) 500))); /* { dg-error "priorities" } */
27
28 /* Integer variables are not allowed. */
29 int i;
30 void c5()
31 __attribute__((constructor ((i)))); /* { dg-error "priorities" } */
32 void d5()
33 __attribute__((destructor ((i)))); /* { dg-error "priorities" } */
34
35 /* Enumeration constants are allowed. */
36 enum E { e = 500 };
37 void c6()
38 __attribute__((constructor ((e))));
39 void d6()
40 __attribute__((destructor ((e))));