| 1 |
// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -verify %s |
| 2 |
// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -DSYSTEM -verify %s |
| 3 |
// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -DNOERROR -Wno-error=init-priority-reserved -verify %s |
| 4 |
// RUN: %clang_cc1 -triple=s390x-none-zos -fsyntax-only -verify=unknown %s |
| 5 |
// RUN: %clang_cc1 -triple=s390x-none-zos -fsyntax-only -DSYSTEM -verify=unknown-system %s |
| 6 |
|
| 7 |
#if defined(SYSTEM) |
| 8 |
#5 "init-priority-attr.cpp" 3 // system header |
| 9 |
#endif |
| 10 |
|
| 11 |
class Two { |
| 12 |
private: |
| 13 |
int i, j, k; |
| 14 |
public: |
| 15 |
static int count; |
| 16 |
Two( int ii, int jj ) { i = ii; j = jj; k = count++; }; |
| 17 |
Two( void ) { i = 0; j = 0; k = count++; }; |
| 18 |
int eye( void ) { return i; }; |
| 19 |
int jay( void ) { return j; }; |
| 20 |
int kay( void ) { return k; }; |
| 21 |
}; |
| 22 |
|
| 23 |
extern Two foo; |
| 24 |
extern Two goo; |
| 25 |
extern Two coo[]; |
| 26 |
extern Two koo[]; |
| 27 |
|
| 28 |
// unknown-system-no-diagnostics |
| 29 |
|
| 30 |
Two foo __attribute__((init_priority(101))) ( 5, 6 ); |
| 31 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 32 |
|
| 33 |
Two loo __attribute__((init_priority(65535))) ( 5, 6 ); |
| 34 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 35 |
|
| 36 |
Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{'init_priority' attribute takes one argument}} |
| 37 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 38 |
|
| 39 |
Two coo[2] __attribute__((init_priority(100))); |
| 40 |
#if !defined(SYSTEM) |
| 41 |
#if !defined(NOERROR) |
| 42 |
// expected-error@-3 {{requested 'init_priority' 100 is reserved for internal use}} |
| 43 |
#else // defined(NOERROR) |
| 44 |
// expected-warning@-5 {{requested 'init_priority' 100 is reserved for internal use}} |
| 45 |
#endif // !defined(NOERROR) |
| 46 |
// unknown-warning@-7 {{unknown attribute 'init_priority' ignored}} |
| 47 |
#endif // !defined(SYSTEM) |
| 48 |
|
| 49 |
Two zoo[2] __attribute__((init_priority(-1))); // expected-error {{'init_priority' attribute requires integer constant between 0 and 65535 inclusive}} |
| 50 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 51 |
|
| 52 |
Two boo[2] __attribute__((init_priority(65536))); // expected-error {{'init_priority' attribute requires integer constant between 0 and 65535 inclusive}} |
| 53 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 54 |
|
| 55 |
Two koo[4] __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}} |
| 56 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 57 |
|
| 58 |
Two func() __attribute__((init_priority(1001))); // expected-error {{'init_priority' attribute only applies to variables}} |
| 59 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 60 |
|
| 61 |
int i __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}} |
| 62 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 63 |
|
| 64 |
int main() { |
| 65 |
Two foo __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}} |
| 66 |
// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}} |
| 67 |
} |